home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / formats / urt / rle.ps < prev    next >
Text File  |  1994-10-02  |  68KB  |  2,475 lines

  1. %!
  2. %!
  3. /md 200 dict def md begin /av 13 def /mtx matrix currentmatrix def /s30 30
  4. string def /s1( )def /pys 1 def /pxs 1 def /pyt 760 def /pxt 29.52 def /por
  5. true def /xl{translate}def /fp{pnsh 0 ne pnsv 0 ne and}def /vrb[{fp{gsave 1
  6. setlinewidth pnsh pnsv scale stroke grestore}if newpath}{eofill}{eofill}
  7. {newpath}{eofill}{eofill}{initclip eoclip newpath}{}{}{}{}]def /xdf{exch def}
  8. def currentscreen /spf xdf /rot xdf /freq xdf /doop{vrb exch get exec}def /psu
  9. {2 index .72 mul exch div /pys xdf div .72 mul /pxs xdf 36 sub /pyt xdf 36 sub
  10. /pxt xdf /por xdf}def /txpose{dup 1680 eq{{1320 1680 div dup scale}if}dup 1212
  11. eq{54 32.4 xl}if 1321 eq{8.64 -.6 xl}if pxs pys scale pxt pyt xl por not{270
  12. rotate}if 1 -1 scale}def /obl{{0.212557 mul}{pop 0}ifelse}def /sfd{[ps 0 ps 6
  13. -1 roll obl ps neg 0 0]makefont dup setfont}def /fnt{findfont sfd}def /bt{1
  14. index and 0 ne exch}def /sa 6 array def /fs{1 bt 2 bt 4 bt 8 bt 16 bt sa astore
  15. pop}def /matrix1 matrix def /matrix2 matrix def /gf{currentfont}def /tc{32768
  16. div add 3 1 roll 32768 div add 2t astore pop}def /3a[0 0 0]def /2t 2 array def
  17. /tp{3a astore pop}def /ee{}def /tt{gsave currentpoint 2 copy 2t aload pop qa 2
  18. copy xl 3a aload pop exch dup 0 eq{pop}{1 eq{-1 1}{1 -1}ifelse scale}ifelse
  19. rotate pop neg exch neg exch xl moveto}def /te{currentpoint currentfont
  20. grestore setfont moveto}def /tb{/tg currentgray def 3 -1 roll 3 eq{1 setgray}
  21. if /ml 0 def /al 0 def}def /am{ml add /ml xdf}def /aa{[currentgray /setgray cvx
  22. ]cvx exch dup wi pop dup al add /al xdf exch}def /th{3 -1 roll div 3 1 roll
  23. exch div 2 copy matrix1 transform scale pop scale /scaleflag true def}def /tu{
  24. 1 1 matrix1 itransform scale /scaleflag false def}def /ts{1 1 matrix1 transform
  25. scale /scaleflag true def}def /fz{/ps xdf}def /fx{dup exec}def /st{show pop pop
  26. }def /tm{{dup type dup /integertype eq exch /realtype eq or{dup ml mul}{dup
  27. type /stringtype eq{rs}{dup type /dicttype eq{setfont}{dup type /arraytype eq
  28. {exec}{pop}ifelse}ifelse}ifelse}ifelse}forall}def /es{3 -1 roll dup sa 5 get
  29. dup type /nulltype eq{pop4 pop}{sa 1 get{/ml ml .2 ps mul sub def}if ne{fs}
  30. {pop}ifelse exch dup 1 eq{pop al ml gt{/tv{ll}/ml ml al dup 0 ne{div}{pop}
  31. ifelse def}{/tv{st}/ml 1 def}ifelse def tm}{dup 3 eq{pop al ml gt{/tv{ll}/ml ml
  32. al dup 0 ne{div}{pop}ifelse def}{ml al sub 0 rmoveto /tv{st}/ml 1 def}ifelse
  33. def tm}{2 eq{al ml gt{/tv{ll}/ml ml al dup 0 ne{div}{pop}ifelse def}{ml al sub
  34. 2 div 0 rmoveto /tv{st}/ml 1 def}ifelse def tm}{/tv{ll}def /ml ml al dup 0 ne
  35. {div}{pop}ifelse def tm}ifelse}ifelse}ifelse}ifelse tg setgray}def /pop4{pop
  36. pop pop pop}def /gm{scaleflag{matrix1 itransform}if moveto}def /ly{exch pop
  37. currentpoint exch pop sub 0 exch rmoveto}def /page{pop}def /sk{systemdict
  38. /statusdict known}def /jn{sk{statusdict /jobname 3 -1 roll put}{pop}ifelse}def
  39. /pen{/pnsv xdf /pnsh xdf pnsh setlinewidth}def /dlin{currentpoint newpath
  40. moveto lineto currentpoint stroke grestore moveto}def /lin{currentpoint /pnlv
  41. xdf /pnlh xdf gsave newpath /@y xdf /@x xdf fp{pnlh @x lt{pnlv @y ge{pnlh pnlv
  42. moveto @x @y lineto pnsh 0 rlineto 0 pnsv rlineto pnlh pnsh add pnlv pnsv add
  43. lineto pnsh neg 0 rlineto}{pnlh pnlv moveto pnsh 0 rlineto @x pnsh add @y
  44. lineto 0 pnsv rlineto pnsh neg 0 rlineto pnlh pnlv pnsv add lineto}ifelse}
  45. {pnlv @y gt{@x @y moveto pnsh 0 rlineto pnlh pnsh add pnlv lineto 0 pnsv
  46. rlineto pnsh neg 0 rlineto @x @y pnsv add lineto}{pnlh pnlv moveto pnsh 0
  47. rlineto 0 pnsv rlineto @x pnsh add @y pnsv add lineto pnsh neg 0 rlineto 0 pnsv
  48. neg rlineto}ifelse}ifelse closepath fill}if @x @y grestore moveto}def /dl{
  49. gsave 0 setlinewidth 0 setgray}def /barc{/@f xdf /@op xdf /@e xdf /@s xdf /@r
  50. xdf /@b xdf /@l xdf /@t xdf gsave @r @l add 2 div @b @t add 2 div xl 0 0 moveto
  51. @r @l sub @b @t sub mtx currentmatrix pop scale @f{newpath}if 0 0 0.5 @s @e arc
  52. mtx setmatrix @op doop grestore}def /doarc{dup 0 eq barc}def /doval{0 exch 360
  53. exch true barc}def /dorect{/@op xdf currentpoint 6 2 roll newpath 4 copy 4 2
  54. roll exch moveto 6 -1 roll lineto lineto lineto closepath @op doop moveto}def
  55. /mup{dup pnsh 2 div le exch pnsv 2 div le or}def /dorrect{/@op xdf 2. div /@h
  56. xdf 2. div /@w xdf /@r xdf /@b xdf /@l xdf /@t xdf @t @b eq @l @r eq @w mup or
  57. or{@t @l @b @r @op dorect}{@r @l sub 2. div dup @w lt{/@w xdf}{pop}ifelse @b @t
  58. sub 2. div dup @w lt{/@w xdf}{pop}ifelse @op 0 eq{/@w @w pnsh 2 div sub def}if
  59. currentpoint newpath @r @l add 2. div @t moveto @r @t @r @b @w arcto pop4 @r @b
  60. @l @b @w arcto pop4 @l @b @l @t @w arcto pop4 @l @t @r @t @w arcto pop4
  61. closepath @op doop moveto}ifelse}def /pr{gsave newpath /pl{moveto /pl{lineto}
  62. def}def}def /pl{lineto}def /ep{dup 0 eq{{moveto}{lin}{}{}pathforall pop
  63. grestore}{doop grestore}ifelse}def /bs 8 string def /bd{/bs xdf}def /bit{bs
  64. exch get exch 7 sub bitshift 1 and}def /bix{1 add 4 mul cvi}def /pp{exch bix
  65. exch bix bit}def /grlevel{64. div setgray}def /setpat{/bs xdf 9.375 0{pp}
  66. setscreen grlevel}def /setgry{freq rot{spf}setscreen grlevel}def /x4{2 bitshift
  67. }def /d4{-2 bitshift}def /xf{.96 mul exch 2 sub .96 mul exch}def /dobits{
  68. /bmode xdf save 9 1 roll{x4 /@dy xdf 2 sub x4 /@dx xdf /@idx xdf .96 mul exch 2
  69. sub exch xl 0 0 moveto xf 0 2 2 index 4 index 1.759 add 10 dorect clip newpath
  70. 0 0 moveto scale bmode 0 eq bmode 4 eq or{1 setgray 1 @dy div 1 @dx div 1 1 2
  71. dorect}if bmode 3 eq bmode 7 eq or{1}{0}ifelse setgray @idx 5 bitshift @dy
  72. bmode 4 eq bmode 5 eq bmode 7 eq or or[@dx 0 0 @dy 0 0]{(%stdin)(r)file @dy d4
  73. 4 add @idx mul string readhexstring pop dup length @idx x4 sub 4 bitshift
  74. string dup 3 1 roll @dx 8 add d4 smooth}imagemask}{/@dy xdf 2 sub /@dx xdf
  75. /@idx xdf /@xs @idx string def /@f(%stdin)(r)file def /@p{@f @xs readhexstring
  76. pop}def .96 mul xl 0 0 moveto xf scale 0 0 1 1 10 dorect clip newpath 0 0
  77. moveto bmode 0 eq bmode 4 eq or{1 setgray .25 @dy div .25 @dx div 1 1 2 dorect
  78. }if bmode 3 eq bmode 7 eq or{1}{0}ifelse setgray @p @p @idx 3 bitshift @dy
  79. bmode 0 eq bmode 1 eq bmode 3 eq or or[@dx 0 0 @dy 0 0]{@p}imagemask @p @p pop4
  80. }ifelse restore}def /mfont 14 dict def /wd 14 dict def /mdef{mfont wcheck not
  81. {/mfont 14 dict def}if mfont begin xdf end}def /dc{transform round .5 sub exch
  82. round .5 sub exch itransform}def /cf{{1 index /FID ne{tmp 3 1 roll put}{pop pop
  83. }ifelse}forall}def /mv{tmp /Encoding macvec put}def /bf{mfont begin /FontType 3
  84. def /FontMatrix[1 0 0 1 0 0]def /FontBBox[0 0 1 1]def /Encoding macvec def
  85. /BuildChar{wd begin /cr xdf /fd xdf fd /low get cr get 2 get -1 ne{fd begin low
  86. cr get aload pop sd low cr 1 add get 0 get sh sw end /sw xdf /sh xdf sw div
  87. /clocn xdf dup 0 ne{0 exch sh div neg dc xl}{pop}ifelse exch sw div /coff xdf
  88. exch sw div /cloc xdf /bitw clocn cloc sub def sw sh div 1 scale sw div 0 coff
  89. 0 bitw coff add 1 setcachedevice coff cloc sub 0 dc xl cloc .5 sw div add 0 dc
  90. newpath moveto bitw 0 ne{0 1 rlineto bitw .5 sw div sub 0 rlineto 0 -1 rlineto
  91. closepath clip sw sh false[sw 0 0 sh neg 0 sh]{fd /hm get}imagemask}if}if end}
  92. def end mfont definefont pop}def /wi{save exch /show{pop}def stringwidth 3 -1
  93. roll restore}def /aps{0 get 124 eq}def /apn{s30 cvs aps}def /xc{s30 cvs dup
  94. }def /xp{put cvn}def /scs{xc 3 67 put dup 0 95 xp}def /sos{xc 3 79 xp}def /sbs
  95. {xc 1 66 xp}def /sis{xc 2 73 xp}def /sob{xc 2 79 xp}def /sss{xc 4 83 xp}def /dd
  96. {exch 1 index add 3 1 roll add exch}def /smc{moveto dup show}def /kwn{dup
  97. FontDirectory exch known{findfont exch pop}}def /fb{/ps ps 1 add def}def /mb
  98. {dup sbs kwn{exch{pop}{bbc}{}mm}ifelse sfd}def /mo{dup sos kwn{exch{pop}{boc}{
  99. }mm}ifelse sfd}def /ms{dup sss kwn{exch{pop}{bsc}{}mm}ifelse sfd}def /ao{dup
  100. sos kwn{exch dup ac pop{scs findfont /df2 xdf}{aoc}{}mm}ifelse sfd}def /as{dup
  101. sss kwn{exch dup ac pop{scs findfont /df2 xdf}{asc}{}mm}ifelse sfd}def /ac{dup
  102. scs kwn{exch /ofd exch findfont def /tmp ofd maxlength 1 add dict def ofd cf mv
  103. tmp /PaintType 1 put tmp definefont}ifelse}def /mm{/mfont 10 dict def mfont
  104. begin /FontMatrix[1 0 0 1 0 0]def /FontType 3 def /Encoding macvec def /df 4
  105. index findfont def /FontBBox[0 0 1 1]def /xda xdf /mbc xdf /BuildChar{wd begin
  106. /cr xdf /fd xdf /cs s1 dup 0 cr put def fd /mbc get exec end}def exec end mfont
  107. definefont}def /bbc{/da .03 def fd /df get setfont gsave cs wi exch da add
  108. exchd grestore setcharwidth cs 0 0 smc da 0 smc da da smc 0 da moveto show}def
  109. /boc{/da 1 ps div def fd /df get setfont gsave cs wi exch da add exch grestore
  110. setcharwidth cs 0 0 smc da 0 smc da da smc 0 da smc 1 setgray da 2. div dup
  111. moveto show}def /bsc{/da 1 ps div def /ds .05 def /da2 da 2. div def fd /df get
  112. setfont gsave cs wi exch ds add da2 add exch grestore setcharwidth cs ds da2
  113. add .01 add 0 smc 0 ds da2 sub xl 0 0 smc da 0 smc da da smc 0 da smc 1 setgray
  114. da 2. div dup moveto show}def /aoc{fd /df get setfont gsave cs wi grestore
  115. setcharwidth 1 setgray cs 0 0 smc fd /df2 get setfont 0 setgray 0 0 moveto show
  116. }def /asc{/da .05 def fd /df get setfont gsave cs wi exch da add exch grestore
  117. setcharwidth cs da .01 add 0 smc 0 da xl 1 setgray 0 0 smc 0 setgray fd /df2
  118. get setfont 0 0 moveto show}def /T true def /F false def /6a 6 array def /2a 2
  119. array def /5a 5 array def /qs{3 -1 roll sub exch 3 -1 roll sub exch}def /qa{3
  120. -1 roll add exch 3 -1 roll add exch}def /qm{3 -1 roll 1 index mul 3 1 roll mul
  121. }def /qn{6a exch get mul}def /qA .166667 def /qB .833333 def /qC .5 def /qx{6a
  122. astore pop qA 0 qn qB 2 qn add qA 1 qn qB 3 qn add qB 2 qn qA 4 qn add qB 3 qn
  123. qA 5 qn add qC 2 qn qC 4 qn add qC 3 qn qC 5 qn add}def /qp{6 copy 12 -2 roll
  124. pop pop}def /qc{qp qx curveto}def /qi{{4 copy 2a astore aload pop qa .5 qm
  125. newpath moveto}{2 copy 6 -2 roll 2 qm qs 4 2 roll}ifelse}def /qq{{qc 2a aload
  126. pop qx curveto}{4 copy qs qa qx curveto}ifelse}def /pt{gsave currentpoint
  127. newpath moveto}def /qf{gsave eofill grestore}def /tr{currentgray currentscreen
  128. bs 5a astore pop /fillflag 1 def}def /bc{/fillflag 0 def}def /ec{currentpoint 3
  129. -1 roll 1 and 0 ne{currentgray currentscreen bs 5a aload pop bd setscreen
  130. setgray 0 doop bd setscreen setgray}{newpath}ifelse moveto}def /bp{
  131. currentpoint newpath 2 copy moveto currentgray currentscreen bs 5a astore pop}
  132. def /eu{fillflag 0 ne{gsave currentgray currentscreen bs 5a aload pop bd
  133. setscreen setgray 4 ep bd setscreen setgray}if fp{0 ep}{grestore newpath
  134. }ifelse}def /sm{dup 0 exch{32 eq{1 add}if}forall}def /ll{3 1 roll exch dup
  135. .0001 lt 1 index -.0001 gt and{pop pop pop}{sub dup 0 eq{pop show}{1 index sm
  136. dup 0 eq 3 index 0 le or{pop length div 0 3 -1 roll ashow}{10 mul exch length
  137. add div dup 10 mul 0 32 4 -1 roll 0 6 -1 roll awidthshow}ifelse}ifelse}ifelse
  138. }def /ss{/pft currentfont def sa aload pop pop /|----2Symbol 4 1 roll{pop{as}}
  139. {{{ao}}{{fnt}}ifelse}ifelse exch pop exec exch pop}def /pf{pft dup setfont}def
  140. /rs{sa 2 get{gsave 1 index 0 currentfont dup /FontInfo known{/FontInfo get dup
  141. /UnderlinePosition known{dup /UnderlinePosition get 1000 div ps mul}{ps 10 div
  142. neg}ifelse exch dup /UnderlineThickness known{/UnderlineThickness get 1000 div
  143. ps mul}{pop ps 15 div}ifelse}{pop ps 10 div neg ps 15 div}ifelse setlinewidth 0
  144. setgray currentpoint 3 -1 roll sub moveto sa 4 get{gsave currentlinewidth 2.
  145. div dup rmoveto currentpoint xl 2 copy rlineto stroke grestore}if sa 3 get sa 4
  146. get or 3 1 roll 2 index{gsave 1 setgray 2 copy rlineto stroke grestore}if
  147. rlineto{strokepath 0 setlinewidth}if stroke grestore}if tv}def /macvec 256
  148. array def macvec 0 /Times-Roman findfont /Encoding get 0 128 getinterval
  149. putinterval macvec 39 /quotesingle put /dotlessi /grave /circumflex /tilde
  150. /cedilla /registerserif /copyrightserif /trademarkserif macvec 0 8 getinterval
  151. astore pop /Adieresis /Aring /Ccedilla /Eacute /Ntilde /Odieresis /Udieresis
  152. /aacute /agrave /acircumflex /adieresis /atilde /aring /ccedilla /eacute
  153. /egrave /ecircumflex /edieresis /iacute /igrave /icircumflex /idieresis /ntilde
  154. /oacute /ograve /ocircumflex /odieresis /otilde /uacute /ugrave /ucircumflex
  155. /udieresis /dagger /ring /cent /sterling /section /bullet /paragraph
  156. /germandbls /registersans /copyrightsans /trademarksans /acute /dieresis
  157. /notequal /AE /Oslash /infinity /plusminus /lessequal /greaterequal /yen /mu
  158. /partialdiff /summation /product /pi /integral /ordfeminine /ordmasculine
  159. /Omega /ae /oslash /questiondown /exclamdown /logicalnot /radical /florin
  160. /approxequal /Delta /guillemotleft /guillemotright /ellipsis /space /Agrave
  161. /Atilde /Otilde /OE /oe /endash /emdash /quotedblleft /quotedblright /quoteleft
  162. /quoteright /divide /lozenge /ydieresis /Ydieresis /fraction /currency
  163. /guilsinglleft /guilsinglright /fi /fl /daggerdbl /periodcentered
  164. /quotesinglbase /quotedblbase /perthousand /Acircumflex /Ecircumflex /Aacute
  165. /Edieresis /Egrave /Iacute /Icircumflex /Idieresis /Igrave /Oacute /Ocircumflex
  166. /apple /Ograve /Uacute /Ucircumflex /Ugrave /dotlessi /asciicircum /asciitilde
  167. /macron /breve /dotaccent /ring /cedilla /hungarumlaut /ogonek /caron macvec
  168. 128 128 getinterval astore pop FontDirectory{exch dup s30 cvs /@s xdf @s aps
  169. {pop pop}{exch dup length dict /tmp xdf cf /Symbol ne{mv}if /@i false def /@o
  170. false def /@b false def mark @s(Italic)search{/@i true def}if(Oblique)search
  171. {/@o true def}if(Bold)search{/@b true def}if(Roman)search pop(-)search pop /@s
  172. xdf cleartomark @s cvn dup /Symbol eq{pop 50}{/Courier eq{51}{49}ifelse}ifelse
  173. s30 0 @s length 6 add getinterval dup 6 @s putinterval dup 0(|-----)
  174. putinterval @b{dup 1 66 put}if @i @o or{dup 2 73 put}if dup 5 4 -1 roll put cvn
  175. tmp definefont pop}ifelse}forall /_--C-2Symbol /Symbol findfont /tmp 1 index
  176. maxlength 1 add dict def cf tmp /PaintType 1 put tmp definefont /|----4Seattle
  177. /Helvetica findfont dup length 1 add dict /tmp xdf cf mv /mxv[/zero /one /two
  178. /three /four /five /six /seven /eight /nine /comma /period /dollar /numbersign
  179. /percent /plus /hyphen /E /parenleft /parenright /space]def tmp /Metrics 21
  180. dict dup begin mxv{600 def}forall end put tmp begin /FontBBox FontBBox[0 0 0 0
  181. ]astore def end tmp definefont pop /od{txpose 10 fz 0 fs F /|----3Courier fnt
  182. pop}def /op{/scaleflag false def /pm save def}def /cp{pm restore}def end
  183. <652E29AE551935C9A82086907FB876D510EC4D451220E0F80D63DBC0EA379346
  184. C055B673F7BED773F332BDE5107DC0B1322DF36267320C226DBEBD9299B29C86
  185. 5D1876ABB7E19F6A45F52C588810FD0A9FFBB1073AD1B6BDCA3D2BAE3283AC88
  186. 35259ADDA98433676B8B757B19473F2C0C3D36AF93B3DD15AFC47F4D3BECB87B
  187. ABAAB5613FCD319A712E7D4A8C5A3C0BA96A376CC93C52ABDE43A980670C1E6B
  188. 78E4D14D5CA032FE07255D5E5A084CCF4B8E23C64F574932EA53E8CD7F00F47B
  189. 4179A6DAFE3BC43B1D091902E6E4B5699C7322FC23B5FBE833E4114C4544E29E
  190. 6225A5B48E6F2A840F44E827681E1AC9F28EB8FEC32105CA4056D863BCAECE65
  191. 1AAF3B12BC38A77CA241A66FAE92939A6EFACD49711E5D7355E634041C378FFC
  192. 1F3BF8B903E5F8961E7480259EB0AA90B0C38E75D264ACE71F1307D4894BFDCF
  193. 9C9D0F3C026BA190A3F6F7E06F3ED092E8CF0D4F22AD6C55C6FED836290F9611
  194. 442BF4DEDBBA0B67D2AF782A796D474ECE7B2B788B4771D4BBCDF0E8F48A2874
  195. D1CF78D3B1C5AA2987C6A22135B1508C7C5EC5AD86ABAE8D1E34A5314F703337
  196. C7A2C0CF52DBBF046F0BD67BE5E65AAD9CE43FAB6E7C9F669801849C9366E5AE
  197. 76C77D8DDBF188CD18C120FEA4C1B510FC00434A2629BB82A9336EB36A5D5552
  198. F4971ED40EF839771762E60509A2A3214DEA9C58C2E53E76CE24B99E3C472719
  199. C66B31A38DE21135FF1390CCA7E0F6B92CEEAF9524317A427DA7CB9B4ED08BF0
  200. 9868FCD9ECAAFF2C520E0EAAB8730FD6CE85B4ACAEE82FC53C5D948C8858A8A3
  201. CF945546556FB3DC9CE69D87BD793DAC57E3F4FB9D056C163C3EE134EDDF7B7D
  202. 186C9A0D79759CD9BF94A4B1E2A6070727DFC08806828B53799090725D4B2D6E
  203. 9BCB6C2B90AA4E47D1774F3A58868E4EB3464C7FB07854CE66E3AB03A5D515A1
  204. 69AC0EA62BAE9A2A419C9AAB14F09A864F4228A098FB288B60E87B85EB16A6D4
  205. EF27B835BAC40E45BF48F78E6CE74AE0C1E81316F630BFE0D7661116B6A92187
  206. 9A1036437280BDA64F85CB37CA0DDBF827C3E4885F1C75E3C84CB8EBED892810
  207. 450DA08029A611AEE126FD6BEFF6830EDA28E4C54649D93C23270703B2F7FEAA
  208. A6524192A2D7F1151B2827EF4B27C823D385EA683F024299B1EFE64871AFD4CD
  209. 6C54C484AA53030CC7F8254BF9E525A00E51867660A3409BECA98DEB37A568F6
  210. D1026ECBFCCF8C9B9BFD11CE017CB2271E7BDEE1D459FFA23062D5B42552C04B
  211. 9BC02C0D7F5CC926ABE694A185FDE2ECC76506DEF1435CBC1225475E4D98A04C
  212. 2CF1DD03915DEB659BC23DE29A6E6734CF49CE39A1BF450A55B0F14D350E79B0
  213. 5C690B84003AB669678B3A416828F376F78946C44009A14A49ED90980B6E4589
  214. 56D188D9AC3FA7F781C8670C83B403B73237B6B0C2862C51C33D559C005D6C9D
  215. D39914B79DBE81291EF8D7CE3EC844176FB7C08A6F344E26C0563C29FCC3B0CB
  216. 2CCCF9412832300CBCDE6BFF39A8804ACCB8375752EEECB1BBA0851ED8DF9E17
  217. 4A5C747E354402DE217C6A7DE35BDE29F50284F66EC5F9DC0032FE3E05842472
  218. 6F9E50555FCBEFF246264D503DCFEB5C5F3384798E5C622FD0450DC62DCE36CA
  219. 9007DBA236A7CE56A57C0B0C531AC5766684DE4BDD2DFEC3BA4D99B930B2EDB2
  220. 0C2AC0F032BB6E5C75AF97AE24DD7FF33FA0F643BBB39331E7E4A474ED5612A1
  221. 7AEF558F8281D4E9EC01AC3D04C4A4C4B8A67F7A6199BA35448298E177554A20
  222. 81DFA1E8D1BC88BDB9938CFEC498918BF3AD690924F295A03D17F28C5FF47F43
  223. D495B74827BD54A2524F53750D4C030843986C97B59A63E08EFB9B14582088BA
  224. FC257BCEF07F2E4B8DCADCC9FAEF7388055483470D5FA4A8CE8CC118CA91FAA5
  225. B0DCCC7F3638A2F9F40628186990C2EE0E25B0FB34DAD8521A6735485ADBE4DD
  226. 7A937036C5EF7E741FF4543FDEE19DD0CFF59A89656F80F8E5E84C10878CB651
  227. 0DD3C3C7A346AC1877FFA88E5ADDCFF95D37163A5350AA5C71BB801ACB0D0FA1
  228. 154DE2C2D039CAAB85F389554044E8F90F9992DEBCCBEACE55F69E31061FB052
  229. A25343ECBEDE16C8999218AF370378901B36655D83D4B9BC5F4F43B361BB2134
  230. 3A88E0350E5C4342407DEFA79877B3C5DAFE15B0F58520FDBE5B8362BE3549AE
  231. 03BD77CDFEC962C539252312ECC5D841F55BEBAD9F7BB03A2D2CAC844E82A568
  232. 7CB2D8E599E356D9A23802439B056F1CC104F9F0D3F01EE2593C59483154FCCA
  233. 3973F487593C9DE94FC0863B6669100B46AFC5B261493A4B50CB9F802EBC31AB
  234. 7B7903A1957EA078A0C4D90E204E44335131C9B65F15D3E5C9A87ADAA7FE5E49
  235. D3654F021F460E5E2AC56A69E8F50E45B0D859D8EC27333DF2AE409015973D7E
  236. ED59F45720DD271D081F3DF62032358E0D4B1D4A528FB4E96A6B2007E13E55E2
  237. 10DAED32AF76F3396D60295D116EC4EE4D42DF4BC764ED9BC11A369FE070815F
  238. FEB5662551561354788EFA98612D09BC964428767E0CBE5DC3EC5B599E9B2074
  239. AA3D446752A4E34485C3D111034676AF67EE5345263E883CF46C8BEF1BD4D51D
  240. D2B625481880254888AB0C186E2D0549F657E59026E2A3C49FE0DFD2A2CAD076
  241. 586B6F248C11E81C41F9525A5D2F77CE5D76FD9104F39F4E4E31CF75045A9061
  242. B16B20CDC2AFD0595F5B6ADF45CA0DC6A37C4ED090AADCFE9EA7847217777A8E
  243. 88C7FBC247EC02973EF656BF1A4A2E71ED21142EC48CC9FDBF5EAE8B46C3E477
  244. 59D9C304C6862D43AF1DE66B44B4AC18B47C6518FA5747D3D8C9A19612DAEE4E
  245. 83C141561421A1360FD847997148932568D3E6CA93BF0D5874BCD90A3A363739
  246. 1FAD35F574797D6160BD4F1AEC3A326D5D73C9BD699C41524B18BC6CDF9169E7
  247. 51FFAB19B9FD7ABE3B2F9D3E0F67ADB05CA85D484ACBC84E287DAA1EDC3BCD95
  248. 694EF05F77A59004B1C3E223AA4A5A063EC238B4A5A25D335FA51B165963621F
  249. 57B7F2C54E59CFED574370399A03E2DFB0F1E35678A6A509A912ED27AD755C67
  250. E045CC1CFEFE41CAD8EA73DD666757D90170EF9C3F218120F38FC1D38224160E
  251. 7F5DE6BDF39665FF231079296B94A7DE674847D299C711E77C9DA408FF9CDCFA
  252. 8F7FE175BE275EB0AE21512D074DBDDCF1CDF75642EF656E2555F9F3E60A2822
  253. F214CC81EEF0E4866387799F21B1F4B296E7F3A2206795457A33E85B397A5F20
  254. 10809D1F43B2267BD762A6CC12DF31BB0817496FE666A6955CD2BA96549B4D1F
  255. 827E54A835ABA03B1079F1F5C3C4D2F4F698D3C235BDFA829F079A0DCF788913
  256. 77B31EBACF4E61A01487ED1F80ABBF5CF000B1EAA8527EC6064AB06B921916CB
  257. 65045B86E9BB2D2E854C5124C218B6FDA0732ABF424EE1696BC86F8987E48CC5
  258. 038C8A557E9534A48E7C55F21F021AA7A370A7CC1B55E777972883433F454450
  259. D18ABFC489D5AA518171884FB7103D92E479ECAEA449341F7C8DB1BD39ECB1ED
  260. 45AF5D9628EF37CAF8DB3C9A65856A97FB9698DD68F8BE27B3C4174F1838C7A0
  261. 674A9460333A059BF214C0690F35BC0352AF9B82CB0F46EAE63A3C0302B4118D
  262. 9E65479030F1EFE34909FA458E31A500483B68601B480D51B7FFCD004A1B5360
  263. 905B88019BC3EF0FF064AC6477442573C18EF7090E2C08EAA1A9> eexec
  264. %!PS-Adobe-1.0
  265. %%Title: rle.mss
  266. %%DocumentFonts: (atend)
  267. %%Creator: John W Peterson and Scribe 5(1501)
  268. %%CreationDate: 8 November 1987 14:56
  269. %%Pages: (atend)
  270. %%EndComments
  271. % PostScript Prelude for Scribe.
  272. /BS {/SV save def 0.0 792.0 translate .01 -.01 scale} bind def
  273. /ES {showpage SV restore} bind def
  274. /SC {setrgbcolor} bind def
  275. /FMTX matrix def
  276. /RDF {WFT SLT 0.0 eq
  277.   {SSZ 0.0 0.0 SSZ neg 0.0 0.0 FMTX astore}
  278.   {SSZ 0.0 SLT sin SLT cos div SSZ mul SSZ neg 0.0 0.0 FMTX astore}
  279.   ifelse makefont setfont} bind def
  280. /SLT 0.0 def
  281. /SI { /SLT exch cvr def RDF} bind def
  282. /WFT /Courier findfont def
  283. /SF { /WFT exch findfont def RDF} bind def
  284. /SSZ 1000.0 def
  285. /SS { /SSZ exch 100.0 mul def RDF} bind def
  286. /AF { /WFT exch findfont def /SSZ exch 100.0 mul def RDF} bind def
  287. /MT /moveto load def
  288. /XM {currentpoint exch pop moveto} bind def
  289. /UL {gsave newpath moveto dup 2.0 div 0.0 exch rmoveto
  290.    setlinewidth 0.0 rlineto stroke grestore} bind def
  291. /LH {gsave newpath moveto setlinewidth
  292.    0.0 rlineto
  293.    gsave stroke grestore} bind def
  294. /LV {gsave newpath moveto setlinewidth
  295.    0.0 exch rlineto
  296.    gsave stroke grestore} bind def
  297. /BX {gsave newpath moveto setlinewidth
  298.    exch
  299.    dup 0.0 rlineto
  300.    exch 0.0 exch neg rlineto
  301.    neg 0.0 rlineto
  302.    closepath
  303.    gsave stroke grestore} bind def
  304. /BX1 {grestore} bind def
  305. /BX2 {setlinewidth 1 setgray stroke grestore} bind def
  306. /PB {/PV save def translate 100.0 -100.0 scale pop} bind def
  307. /PE {PV restore} bind def
  308. /SH /show load def
  309. /MX {exch show 0.0 rmoveto} bind def
  310. /W {0 32 4 -1 roll widthshow} bind def
  311. /WX {0 32 5 -1 roll widthshow 0.0 rmoveto} bind def
  312. %%EndProlog
  313. %%Page: 0 1 
  314. BS
  315. 0 SI
  316. 15 /Times-Bold AF
  317. 20328 8205 MT
  318. (Design of the Utah RLE Format)SH
  319. 10 /Times-Roman AF
  320. 26531 10411 MT
  321. (Spencer W. Thomas)SH
  322. 19893 12840 MT
  323. (University of Utah, Department of Computer Science)SH
  324. 13 /Times-Bold AF
  325. 28181 24323 MT
  326. (Abstract)SH
  327. 9 /Times-Roman AF
  328. 9617 26627 MT
  329. (The Utah RLE \050Run Length Encoded\051 format is designed to provide an efficient, device independent means)
  330. 5 W( of storing)4 W
  331. 9000 27641 MT
  332. (multi-level raster images.  Images of)
  333. 108 W( arbitrary size and depth can be saved.  The design of the format is presented,)109 W
  334. 9000 28655 MT
  335. (followed by descriptions of the library routines used to create and read RLE format files.)SH
  336. 12 /Times-Bold AF
  337. 7200 32339 MT
  338. (1. Introduction)SH
  339. 10 /Times-Roman AF
  340. 8200 33444 MT
  341. (The Utah RLE \050Run Length Encoded\051 format is designed to provide an efficient, device independent)
  342. 101 W( means of)100 W
  343. 7200 34549 MT
  344. (storing multi-level raster images.  It is not designed for binary \050bitmap\051 images.  It is built on several)
  345. 11 W( basic concepts.)12 W
  346. 7200 35654 MT
  347. (The central concept is that of a)120 W
  348. /Times-Italic SF
  349. 20619 XM
  350. (channel)SH
  351. /Times-Roman SF
  352. (. A)
  353. 488 W( channel corresponds to a single color, thus there are normally a red)119 W
  354. 7200 36759 MT
  355. (channel, a green channel, and a blue channel.  Up to 255 color channels are available for use; one)
  356. 178 W( channel is)179 W
  357. 7200 37864 MT
  358. (reserved for "alpha" data.)
  359. 128 W( Although)
  360. 505 W( the format supports arbitrarily deep channels, the current implementation is)127 W
  361. 7200 38969 MT
  362. (restricted to 8 bits per channel.)SH
  363. 8200 41176 MT
  364. (Image data is stored in an RLE file in a scanline form, with the data)
  365. 107 W( for each channel of the scanline grouped)108 W
  366. 7200 42281 MT
  367. (together. Runs)
  368. 342 W( of identical pixel values are compressed into a count)
  369. 46 W( and a value.  However, sequences of differing)45 W
  370. 7200 43386 MT
  371. (pixels are also stored efficiently \050not as a sequence of single pixel runs\051.)SH
  372. 8200 45593 MT
  373. (The file header contains)
  374. 7 W( a large amount of information about the image, including its size, the number of channels)8 W
  375. 7200 46698 MT
  376. (saved, whether it has an alpha channel, an optional color map, and comments.)
  377. 63 W( The)
  378. 374 W( comments may be used to add)62 W
  379. 7200 47803 MT
  380. (arbitrary extra information to the saved image.)SH
  381. 8200 50010 MT
  382. (A subroutine)
  383. 179 W( interface has been written to allow programs to read and write files in the RLE format.  Two)180 W
  384. 7200 51115 MT
  385. (interfaces are available, one that completely interprets the RLE file and returns scanline)
  386. 128 W( pixel data, and one that)127 W
  387. 7200 52220 MT
  388. (returns a list of "raw")
  389. 37 W( run and pixel data.  The second is more efficient, but more difficult to use, the first is easy to)38 W
  390. 7200 53325 MT
  391. (use, but slower.)SH
  392. 8200 55532 MT
  393. (The Utah RLE format has been)
  394. 90 W( used to save images from many sources, and to display saved images on many)89 W
  395. 7200 56637 MT
  396. (different displays and from many different computers.)SH
  397. 12 /Times-Bold AF
  398. 7200 60321 MT
  399. (2. Description of RLE Format)SH
  400. 10 /Times-Roman AF
  401. 8200 61426 MT
  402. (All data in the RLE file is treated as a)
  403. 43 W( byte stream.  Where quantities larger than 8 bits occur, they are written in)44 W
  404. 7200 62531 MT
  405. (PDP-11 byte order \050low order byte first\051.)SH
  406. 8200 64738 MT
  407. (The RLE file consists of two parts, a header followed by scanline data.  The header contains)
  408. 42 W( general information)41 W
  409. 7200 65843 MT
  410. (about the image, while the scanline data is a stream of operations describing the image itself.)SH
  411. ES
  412. %%Page: 1 2 
  413. BS
  414. 0 SI
  415. 10 /Times-Roman AF
  416. 30350 4286 MT
  417. (1)SH
  418. 11 /Times-Bold AF
  419. 7200 7937 MT
  420. (2.1. The Header)SH
  421. 1 SS 
  422. 25200 7200 34242 PB md begin
  423. T 32 760 100 72 72 psu
  424. (rle_hdr; user: )jn
  425. %%Title: rle_hdr
  426. %%Creator: MAC LaserWriter Driver
  427. %%For: 
  428. 1320 od
  429. %%EndProlog
  430. %%Page: ? 1
  431. op
  432. 0 0 xl
  433. 1 1 pen
  434. 0 0 gm
  435. 0 0 720 540 6 dorect
  436. 64 grlevel
  437. 495 144 712 325 4 dorect
  438. 0 grlevel
  439. 495.5 144.5 711.5 324.5 0 dorect
  440. 144 513 gm
  441. 324 513 lin
  442. 200 505 gm
  443. 0 1 6 [tb
  444. {0 fs}fx
  445. {12 fz}fx
  446. %%Changefont: |----1Times
  447. F /|----1Times fnt
  448. 68 am 
  449. (Magic number)aa
  450. ]es
  451. 223 525 gm
  452. 0 1 6 [tb
  453. gf
  454. 23 am 
  455. (xpos)aa
  456. ]es
  457. 223 543 gm
  458. 0 1 6 [tb
  459. gf
  460. 23 am 
  461. (ypos)aa
  462. ]es
  463. 222 561 gm
  464. 0 1 6 [tb
  465. gf
  466. 24 am 
  467. (xsize)aa
  468. ]es
  469. 222 579 gm
  470. 0 1 6 [tb
  471. gf
  472. 24 am 
  473. (ysize)aa
  474. ]es
  475. 178 597 gm
  476. 0 1 6 [tb
  477. gf
  478. 23 am 
  479. (flags)aa
  480. ]es
  481. 234 585 gm
  482. 234 603 lin
  483. 144 531 gm
  484. 324 531 lin
  485. 144 549 gm
  486. 324 549 lin
  487. 144 567 gm
  488. 324 567 lin
  489. 144 585 gm
  490. 324 585 lin
  491. 144 603 gm
  492. 324 603 lin
  493. 144 621 gm
  494. 324 621 lin
  495. 144 639 gm
  496. 324 639 lin
  497. 144 657 gm
  498. 324 657 lin
  499. 144 675 gm
  500. 324 675 lin
  501. 262 597 gm
  502. 0 1 6 [tb
  503. gf
  504. 35 am 
  505. (ncolors)aa
  506. ]es
  507. 234 603 gm
  508. 234 621 lin
  509. 165 615 gm
  510. 0 1 6 [tb
  511. gf
  512. 48 am 
  513. (pixelbytes)aa
  514. ]es
  515. 264 615 gm
  516. 0 1 6 [tb
  517. gf
  518. 31 am 
  519. (ncmap)aa
  520. ]es
  521. 170 633 gm
  522. 0 1 6 [tb
  523. gf
  524. 39 am 
  525. (cmaplen)aa
  526. ]es
  527. 234 621 gm
  528. 234 657 lin
  529. 264 633 gm
  530. 0 1 6 [tb
  531. gf
  532. 30 am 
  533. (red bg)aa
  534. ]es
  535. 169 651 gm
  536. 0 1 6 [tb
  537. gf
  538. 41 am 
  539. (green bg)aa
  540. ]es
  541. 262 651 gm
  542. 0 1 6 [tb
  543. gf
  544. 35 am 
  545. (blue bg)aa
  546. ]es
  547. 193 669 gm
  548. 0 1 6 [tb
  549. gf
  550. 83 am 
  551. (color map entry 0)aa
  552. ]es
  553. 193 687 gm
  554. 0 1 6 [tb
  555. gf
  556. 83 am 
  557. (color map entry 1)aa
  558. ]es
  559. 144 693 gm
  560. 324 693 lin
  561. 228 705 gm
  562. 1 1 6 [tb
  563. {1 fs}fx
  564. {12 fz}fx
  565. %%Changefont: |----1Times
  566. F /|----1Times sbs 
  567. fnt
  568. 13 am 
  569. (╔)aa
  570. ]es
  571. 0 page
  572. cp
  573. %%Page: ? 2
  574. op
  575. -1 page
  576. cp
  577. %%Trailer
  578. end
  579.  PE 10 SS 
  580. 24657 36728 MT
  581. (Figure 2-1:)SH
  582. /Times-Roman SF
  583. 30156 XM
  584. (RLE file header)SH
  585. 8200 38519 MT
  586. (The header has a fixed part and a variable part.  A diagram of the header)
  587. 111 W( is shown in Figure 2-1.  The magic)112 W
  588. 7200 39624 MT
  589. (number identifies the file)
  590. 79 W( as an RLE file.  Following this are the coordinates of the lower left corner of the image)78 W
  591. 7200 40729 MT
  592. (and the size of the image in the X and Y directions.  Images are defined)
  593. 15 W( in a first quadrant coordinate system \050origin)16 W
  594. 7200 41834 MT
  595. (at the lower left, X increasing to the right, Y increasing up.\051  Thus, the image is enclosed in the rectangle)SH
  596. 9200 43354 MT
  597. ([)SH
  598. /Times-Italic SF
  599. (xpos)SH
  600. /Times-Roman SF
  601. (,)SH
  602. /Times-Italic SF
  603. (xpos)SH
  604. /Times-Roman SF
  605. (+)SH
  606. /Times-Italic SF
  607. (xsize)SH
  608. /Symbol SF
  609. (-)SH
  610. /Times-Roman SF
  611. (1])SH
  612. /Times-Italic SF
  613. (X)SH
  614. /Times-Roman SF
  615. ([)SH
  616. /Times-Italic SF
  617. (ypos)SH
  618. /Times-Roman SF
  619. (,)SH
  620. /Times-Italic SF
  621. (ypos)SH
  622. /Times-Roman SF
  623. (+)SH
  624. /Times-Italic SF
  625. (ysize)SH
  626. /Symbol SF
  627. (-)SH
  628. /Times-Roman SF
  629. (1].)SH
  630. 7200 44874 MT
  631. (The position and size are 16 bit integer quantities; images up to 32K square may be saved \050the sizes)
  632. 61 W( should not be)60 W
  633. 7200 45979 MT
  634. (negative\051.)SH
  635. 8200 48186 MT
  636. (A flags byte follows.  There are currently four flags defined:)SH
  637. 9000 49977 MT
  638. (ClearFirst)SH
  639. 18000 XM
  640. (If this flag is set, the image rectangle should first be cleared to the background color)156 W
  641. 18000 51082 MT
  642. (\050q.v.\051 before reading the scanline data.)SH
  643. 9000 52659 MT
  644. (NoBackground)SH
  645. 18000 XM
  646. (If this flag)
  647. 177 W( is set, no background color is supplied, and the ClearFirst flag should be)176 W
  648. 18000 53764 MT
  649. (ignored.)SH
  650. 9000 55341 MT
  651. (Alpha)SH
  652. 18000 XM
  653. (This flag indicates the presence of an "alpha" channel.  The alpha channel is)
  654. 146 W( used by)147 W
  655. 18000 56446 MT
  656. (image compositing software to)
  657. 44 W( correctly blend anti-aliased edges.  It is stored as channel)43 W
  658. 18000 57551 MT
  659. (-1 \050255\051.)SH
  660. 9000 59128 MT
  661. (Comments)SH
  662. 18000 XM
  663. (If this flag is set, comments are present in the variable part of the header, immediately)106 W
  664. 18000 60233 MT
  665. (following the color map.)SH
  666. 8200 61338 MT
  667. (The next)
  668. 15 W( byte is treated as an unsigned 8 bit value, and indicates the number of color channels that were saved.  It)14 W
  669. 7200 62443 MT
  670. (may have any value from 0 to 254 \050channel 255 is reserved for alpha values\051.)SH
  671. 8200 64650 MT
  672. (The)SH
  673. /Times-Italic SF
  674. 10027 XM
  675. (pixelbits)SH
  676. /Times-Roman SF
  677. 13688 XM
  678. (byte gives the number of bits in each pixel.)
  679. 22 W( The)
  680. 296 W( only value currently supported by the software is 8)23 W
  681. 7200 65755 MT
  682. (\050in fact, this byte is currently ignored when reading RLE files\051.  Pixel sizes taking more)
  683. 3 W( than one byte will be packed)2 W
  684. 7200 66860 MT
  685. (low order byte first.)SH
  686. 8200 69067 MT
  687. (The next two bytes describe the size)
  688. 60 W( and shape of the color map.)61 W
  689. /Times-Italic SF
  690. 35348 XM
  691. (Ncmap)SH
  692. /Times-Roman SF
  693. 38492 XM
  694. (is the number of color channels in the)61 W
  695. 7200 70172 MT
  696. (color map.  It need not be identical)
  697. 51 W( to)50 W
  698. /Times-Italic SF
  699. 22877 XM
  700. (ncolors)SH
  701. /Times-Roman SF
  702. (, but interpretation of values of)50 W
  703. /Times-Italic SF
  704. 38814 XM
  705. (ncmap)SH
  706. /Times-Roman SF
  707. 41780 XM
  708. (different from)50 W
  709. /Times-Italic SF
  710. 47767 XM
  711. (0)SH
  712. /Times-Roman SF
  713. (,)SH
  714. /Times-Italic SF
  715. 48817 XM
  716. (1)SH
  717. /Times-Roman SF
  718. (, or)50 W
  719. /Times-Italic SF
  720. 51000 XM
  721. (ncolors)SH
  722. /Times-Roman SF
  723. 7200 71277 MT
  724. (may be ambiguous, unless)51 W
  725. /Times-Italic SF
  726. 18209 XM
  727. (ncolors)SH
  728. /Times-Roman SF
  729. 21510 XM
  730. (is)SH
  731. /Times-Italic SF
  732. 22478 XM
  733. (1)SH
  734. /Times-Roman SF
  735. (. If)352 W
  736. /Times-Italic SF
  737. 24797 XM
  738. (ncmap)SH
  739. /Times-Roman SF
  740. 27764 XM
  741. (is zero, no color map is saved.)51 W
  742. /Times-Italic SF
  743. 40781 XM
  744. (Cmaplen)SH
  745. /Times-Roman SF
  746. 44693 XM
  747. (is the log base 2)
  748. 51 W( of the)52 W
  749. ES
  750. %%Page: 2 3 
  751. BS
  752. 0 SI
  753. 10 /Times-Roman AF
  754. 30350 4286 MT
  755. (2)SH
  756. 7200 7886 MT
  757. (length of each channel of the color)
  758. 42 W( map.  Thus, a value for)41 W
  759. /Times-Italic SF
  760. 31372 XM
  761. (cmaplen)SH
  762. /Times-Roman SF
  763. 35051 XM
  764. (of 8 indicates a color map with 256 entries per)41 W
  765. 7200 8991 MT
  766. (channel.)SH
  767. 8200 11198 MT
  768. (Immediately following the fixed header is the variable part)
  769. 23 W( of the file header.  It starts with the background color.)24 W
  770. 7200 12303 MT
  771. (The background color has)11 W
  772. /Times-Italic SF
  773. 17907 XM
  774. (ncolors)SH
  775. /Times-Roman SF
  776. 21167 XM
  777. (entries; if necessary, it is filled out to an odd number of bytes with a filler byte on)10 W
  778. 7200 13408 MT
  779. (the end \050since the fixed header is an odd number bytes long, this returns to a 16 bit boundary\051.)SH
  780. 8200 15615 MT
  781. (Following the background color is the color map, if present.  Color map values are stored as)
  782. 22 W( 16 bit quantities, left)23 W
  783. 7200 16720 MT
  784. (justified in the)
  785. 37 W( word.  Software interpreting the color map must apply a shift appropriate to the application or to the)36 W
  786. 7200 17825 MT
  787. (hardware being used.  This convention)
  788. 45 W( permits use of the color map without knowing the original output precision.)46 W
  789. 7200 18930 MT
  790. (The channels of the map are stored in increasing numerical order)
  791. 49 W( \050starting with channel 0\051, with the entries of each)48 W
  792. 7200 20035 MT
  793. (channel stored also in increasing order \050starting with entry 0\051.  The color map entries)
  794. 98 W( for each channel are stored)99 W
  795. 7200 21140 MT
  796. (contiguously.)SH
  797. 8200 23347 MT
  798. (Comments, if present, follow the color map.  A 16 bit quantity giving)
  799. 104 W( the length of the comment block comes)103 W
  800. 7200 24452 MT
  801. (first. If)
  802. 344 W( the length is odd, a filler)
  803. 47 W( byte will be present at the end, restoring the 16 bit alignment \050but this byte is not)48 W
  804. 7200 25557 MT
  805. (part of the comments\051.  The comment block contains)
  806. 36 W( any number of null-terminated text strings.  These strings will)35 W
  807. 7200 26662 MT
  808. (conventionally be of the form "name=value", allowing for easy)
  809. 42 W( retrieval of specific information.  However, there is)43 W
  810. 7200 27767 MT
  811. (no restriction that a given name appear only once, and a comment may contain an arbitrary string.  The intent of)
  812. 24 W( the)23 W
  813. 7200 28872 MT
  814. (comment block is to allow information)
  815. 120 W( to be attached to the file that is not specifically provided for in the RLE)121 W
  816. 7200 29977 MT
  817. (format.)SH
  818. 11 /Times-Bold AF
  819. 7200 33594 MT
  820. (2.2. The Scanline Data)SH
  821. 10 /Times-Roman AF
  822. 8200 34699 MT
  823. (The scanline)
  824. 24 W( data consists of a sequence of operations, such as)23 W
  825. /Times-Italic SF
  826. 33726 XM
  827. (Run)SH
  828. /Times-Roman SF
  829. (,)SH
  830. /Times-Italic SF
  831. 35860 XM
  832. (SetChannel)SH
  833. /Times-Roman SF
  834. (, and)23 W
  835. /Times-Italic SF
  836. 42711 XM
  837. (Pixels)SH
  838. /Times-Roman SF
  839. (, describing the actual)23 W
  840. 7200 35804 MT
  841. (image. An)
  842. 364 W( image is stored starting at the lower left corner and proceeding upwards)
  843. 57 W( in order of increasing scanline)58 W
  844. 7200 36909 MT
  845. (number. Each)
  846. 342 W( operation and its associated data takes up an even number of bytes, so that all operations begin on a)45 W
  847. 7200 38014 MT
  848. (16 bit boundary.  This makes the implementation more efficient on many architectures.)SH
  849. 1 SS 
  850. 14400 7200 53519 PB md begin
  851. T 32 760 100 72 72 psu
  852. (rleops; user: )jn
  853. %%Title: rleops
  854. %%Creator: MAC LaserWriter Driver
  855. %%For: 
  856. 1320 od
  857. %%EndProlog
  858. %%Page: ? 1
  859. op
  860. 0 0 xl
  861. 2 2 pen
  862. 0 0 gm
  863. 0 0 720 540 6 dorect
  864. 64 grlevel
  865. 593 134 631 280 4 dorect
  866. 0 grlevel
  867. 594. 135. 630. 279. 0 dorect
  868. 206 593 gm
  869. 206 629 lin
  870. 1 1 pen
  871. 164 615 gm
  872. 0 1 7 [tb
  873. {0 fs}fx
  874. {12 fz}fx
  875. %%Changefont: |----1Times
  876. F /|----1Times fnt
  877. 38 am 
  878. (op-code)aa
  879. ]es
  880. 227 615 gm
  881. 0 1 7 [tb
  882. gf
  883. 38 am 
  884. (operand)aa
  885. ]es
  886. 153 594 gm
  887. 153 630 lin
  888. 138 615 gm
  889. 0 1 7 [tb
  890. gf
  891. 12 am 
  892. (00)aa
  893. ]es
  894. 2 2 pen
  895. 0 0 gm
  896. 64 grlevel
  897. 665 134 703 424 4 dorect
  898. 0 grlevel
  899. 666. 135. 702. 423. 0 dorect
  900. 206 665 gm
  901. 206 701 lin
  902. 278 665 gm
  903. 278 701 lin
  904. 350 665 gm
  905. 350 701 lin
  906. 1 1 pen
  907. 161 687 gm
  908. 0 1 6 [tb
  909. gf
  910. 38 am 
  911. (op-code)aa
  912. ]es
  913. 232 687 gm
  914. 0 1 6 [tb
  915. gf
  916. 22 am 
  917. (filler)aa
  918. ]es
  919. 296 681 gm
  920. 0 1 6 [tb
  921. gf
  922. 38 am 
  923. (operand)aa
  924. ]es
  925. 295 693 gm
  926. 0 1 6 [tb
  927. gf
  928. 41 am 
  929. (low byte)aa
  930. ]es
  931. 368 681 gm
  932. 0 1 6 [tb
  933. gf
  934. 38 am 
  935. (operand)aa
  936. ]es
  937. 365 693 gm
  938. 0 1 6 [tb
  939. gf
  940. 44 am 
  941. (high byte)aa
  942. ]es
  943. 153 666 gm
  944. 153 702 lin
  945. 138 687 gm
  946. 0 1 6 [tb
  947. gf
  948. 12 am 
  949. (01)aa
  950. ]es
  951. 57 615 gm
  952. 0 1 7 [tb
  953. gf
  954. 69 am 
  955. (Short Operand)aa
  956. ]es
  957. 58 687 gm
  958. 0 1 7 [tb
  959. gf
  960. 68 am 
  961. (Long Operand)aa
  962. ]es
  963. 156 651 gm
  964. 0 1 6 [tb
  965. gf
  966. 31 am 
  967. (Byte 0)aa
  968. ]es
  969. 228 651 gm
  970. 0 1 6 [tb
  971. gf
  972. 31 am 
  973. (Byte 1)aa
  974. ]es
  975. 300 651 gm
  976. 0 1 6 [tb
  977. gf
  978. 31 am 
  979. (Byte 2)aa
  980. ]es
  981. 372 651 gm
  982. 0 1 6 [tb
  983. gf
  984. 31 am 
  985. (Byte 3)aa
  986. ]es
  987. 0 page
  988. cp
  989. %%Page: ? 2
  990. op
  991. -1 page
  992. cp
  993. %%Trailer
  994. end
  995.  PE 10 /Times-Bold AF
  996. 22726 56005 MT
  997. (Figure 2-2:)SH
  998. /Times-Roman SF
  999. 28225 XM
  1000. (RLE file operand formats)SH
  1001. 8200 58212 MT
  1002. (Each operation is identified)
  1003. 49 W( by an 8 bit opcode, and may have one or more operands.  Single operand operations)50 W
  1004. 7200 59317 MT
  1005. (fit into a single 16 bit word if the operand value is less than 256.  So)
  1006. 17 W( that operand values are not limited to the range)16 W
  1007. 7200 60422 MT
  1008. (0..255, each operation has a)32 W
  1009. /Times-Italic SF
  1010. 18746 XM
  1011. (long)SH
  1012. /Times-Roman SF
  1013. 20806 XM
  1014. (variant, in which the byte following the opcode is ignored)
  1015. 32 W( and the following word)33 W
  1016. 7200 61527 MT
  1017. (is taken as a 16 bit quantity.  The long variant of an opcode is indicated by setting the bit)
  1018. 58 W( 0x40 in the opcode \050this)57 W
  1019. 7200 62632 MT
  1020. (allows for 64 opcodes,)
  1021. 39 W( of which 6 have been used so far.\051  The two single operand formats are shown pictorially in)40 W
  1022. 7200 63737 MT
  1023. (Figure 2-2.)SH
  1024. 8200 65944 MT
  1025. (The individual operations will now be discussed in detail.)
  1026. 90 W( The)
  1027. 429 W( descriptions are phrased in terms of the actions)89 W
  1028. 7200 67049 MT
  1029. (necessary to interpret the file.  Three indices)
  1030. 46 W( are necessary: the)47 W
  1031. /Times-Italic SF
  1032. 33091 XM
  1033. (current channel)47 W
  1034. /Times-Roman SF
  1035. (, the)47 W
  1036. /Times-Italic SF
  1037. 41564 XM
  1038. (scanline number)47 W
  1039. /Times-Roman SF
  1040. (, and the)47 W
  1041. /Times-Italic SF
  1042. 52056 XM
  1043. (pixel)SH
  1044. 7200 68154 MT
  1045. (index)SH
  1046. /Times-Roman SF
  1047. (. The)570 W
  1048. /Times-Italic SF
  1049. 12401 XM
  1050. (current channel)160 W
  1051. /Times-Roman SF
  1052. 19331 XM
  1053. (is the channel to which data operations apply.  The)160 W
  1054. /Times-Italic SF
  1055. 41511 XM
  1056. (scanline number)159 W
  1057. /Times-Roman SF
  1058. 48717 XM
  1059. (is just the Y)159 W
  1060. 7200 69259 MT
  1061. (position of the scanline in the image.  The)165 W
  1062. /Times-Italic SF
  1063. 25739 XM
  1064. (pixel index)165 W
  1065. /Times-Roman SF
  1066. 30679 XM
  1067. (is the X position of)
  1068. 165 W( the pixel within the scanline.  The)166 W
  1069. 7200 70364 MT
  1070. (operations are:)SH
  1071. ES
  1072. %%Page: 3 4 
  1073. BS
  1074. 0 SI
  1075. 10 /Times-Roman AF
  1076. 30350 4286 MT
  1077. (3)SH
  1078. 9000 7886 MT
  1079. (SkipLines)SH
  1080. 18000 XM
  1081. (Increment the)212 W
  1082. /Times-Italic SF
  1083. 24200 XM
  1084. (scanline number)211 W
  1085. /Times-Roman SF
  1086. 31510 XM
  1087. (by the operand value.  This operation terminates the)211 W
  1088. 18000 8991 MT
  1089. (current scanline.  The)SH
  1090. /Times-Italic SF
  1091. 26914 XM
  1092. (pixel index)SH
  1093. /Times-Roman SF
  1094. 31524 XM
  1095. (should be reset to the xpos value from the header.)SH
  1096. 9000 10568 MT
  1097. (SetColor)SH
  1098. 18000 XM
  1099. (Set the)215 W
  1100. /Times-Italic SF
  1101. 21430 XM
  1102. (current channel)215 W
  1103. /Times-Roman SF
  1104. 28470 XM
  1105. (to the operand value.  This operation does not have)
  1106. 215 W( a long)216 W
  1107. 18000 11673 MT
  1108. (variant. Note)
  1109. 530 W( that an operand value of 255 will be interpreted)
  1110. 140 W( as a)139 W
  1111. /Symbol SF
  1112. 46701 XM
  1113. (-)SH
  1114. /Times-Roman SF
  1115. (1, indicating the)139 W
  1116. 18000 12778 MT
  1117. (alpha channel.  All other operand values)
  1118. 21 W( are positive.  The)22 W
  1119. /Times-Italic SF
  1120. 41814 XM
  1121. (pixel index)22 W
  1122. /Times-Roman SF
  1123. 46468 XM
  1124. (is reset to the xpos)22 W
  1125. 18000 13883 MT
  1126. (value.)SH
  1127. 9000 15460 MT
  1128. (SkipPixels)SH
  1129. 18000 XM
  1130. (Skip over pixels in the)
  1131. 152 W( current scanline.  Increment)151 W
  1132. /Times-Italic SF
  1133. 40026 XM
  1134. (pixel index)151 W
  1135. /Times-Roman SF
  1136. 44938 XM
  1137. (by the operand value.)151 W
  1138. 18000 16565 MT
  1139. (Pixels skipped will be left in the background color.)SH
  1140. 9000 18142 MT
  1141. (PixelData)SH
  1142. 18000 XM
  1143. (Following this opcode is)
  1144. 29 W( a sequence of pixel values.  The length of the sequence is given)30 W
  1145. 18000 19247 MT
  1146. (by the operand value.  If the length of)
  1147. 148 W( the sequence is odd, a filler byte is appended.)147 W
  1148. 18000 20352 MT
  1149. (Pixel values are inserted into the scanline in increasing X order.  The)193 W
  1150. /Times-Italic SF
  1151. 48337 XM
  1152. (pixel index)193 W
  1153. /Times-Roman SF
  1154. 53333 XM
  1155. (is)SH
  1156. 18000 21457 MT
  1157. (incremented by the sequence length.)SH
  1158. 9000 23034 MT
  1159. (Run)SH
  1160. 18000 XM
  1161. (This is the only two operand opcode.  The first operand is the length \050)34 W
  1162. /Times-Italic SF
  1163. (N)SH
  1164. /Times-Roman SF
  1165. (\051 of the run.)
  1166. 34 W( The)316 W
  1167. 8 SS 
  1168. 47918 23802 MT
  1169. (1)SH
  1170. 10 SS 
  1171. 18000 24147 MT
  1172. (second operand is the pixel value, followed by a filler byte if necessary)121 W
  1173. 48318 XM
  1174. (. The)
  1175. 494 W( next)122 W
  1176. /Times-Italic SF
  1177. 53333 XM
  1178. (N)SH
  1179. /Times-Roman SF
  1180. 18000 25252 MT
  1181. (pixels in the scanline are set to)
  1182. 50 W( the given pixel value.  The)49 W
  1183. /Times-Italic SF
  1184. 42084 XM
  1185. (pixel index)49 W
  1186. /Times-Roman SF
  1187. 46792 XM
  1188. (is incremented by)49 W
  1189. /Times-Italic SF
  1190. 18000 26357 MT
  1191. (N)SH
  1192. /Times-Roman SF
  1193. (, to point to the pixel following the run.)SH
  1194. 9000 27934 MT
  1195. (EOF)SH
  1196. 18000 XM
  1197. (This opcode has no operand, and indicates the end of the RLE file.  It)
  1198. 34 W( is provided so that)35 W
  1199. 18000 29039 MT
  1200. (RLE files may be concatenated together and still be correctly)
  1201. 225 W( interpreted.  It is not)224 W
  1202. 18000 30144 MT
  1203. (required, a physical end of file will also indicate the end of the RLE data.)SH
  1204. 11 /Times-Bold AF
  1205. 7200 33761 MT
  1206. (2.3. Subroutine Interface)SH
  1207. 10 /Times-Roman AF
  1208. 8200 34866 MT
  1209. (Two similar subroutine interfaces are provided for)
  1210. 126 W( reading and writing files in the RLE format.  Both read or)127 W
  1211. 7200 35971 MT
  1212. (write a)
  1213. 39 W( scanline worth of data at a time.  A simple "row" interface communicates in terms of arrays of pixel values.)38 W
  1214. 7200 37076 MT
  1215. (It is simple)
  1216. 80 W( to use, but slower than the "raw" interface, which uses a list of "opcode" values as its communication)81 W
  1217. 7200 38181 MT
  1218. (medium.)SH
  1219. 8200 40388 MT
  1220. (In both cases,)
  1221. 194 W( the interface must be initialized by calling a setup function.  The two types of calls may be)193 W
  1222. 7200 41493 MT
  1223. (interleaved; for example, in a rendering program, the background could)
  1224. 60 W( be written using the "raw" interface, while)61 W
  1225. 7200 42598 MT
  1226. (scanlines containing image data could be)
  1227. 120 W( converted with the "row" interface.  The package allows multiple RLE)119 W
  1228. 7200 43703 MT
  1229. (streams to be open simultaneously, as is necessary for use in)
  1230. 22 W( a compositing tool, for example.  All data relevant to a)23 W
  1231. 7200 44808 MT
  1232. (particular RLE stream is contained in a "globals" structure.)SH
  1233. 8200 47015 MT
  1234. (The globals structure echoes the format of the RLE header.  The fields are described below:)SH
  1235. 9000 48806 MT
  1236. (dispatch)SH
  1237. 18000 XM
  1238. (The RLE creation)
  1239. 29 W( routines are capable of writing various types of output files in addition)28 W
  1240. 18000 49911 MT
  1241. (to RLE.  This value is an index into a)
  1242. 230 W( dispatch table.  This value is initialized by)231 W
  1243. /Times-Italic SF
  1244. 18000 51016 MT
  1245. (sv_setup)SH
  1246. /Times-Roman SF
  1247. (.)SH
  1248. 9000 52593 MT
  1249. (ncolors)SH
  1250. 18000 XM
  1251. (The number of color channels in the output file.)
  1252. 53 W( Up)
  1253. 355 W( to this many color channels will be)52 W
  1254. 18000 53698 MT
  1255. (saved, depending on the values in the channel bitmap \050see below\051.)SH
  1256. 9000 55275 MT
  1257. (bg_color)SH
  1258. 18000 XM
  1259. (A pointer to an array of)SH
  1260. /Times-Italic SF
  1261. 27664 XM
  1262. (ncolors)SH
  1263. /Times-Roman SF
  1264. 30914 XM
  1265. (integers containing the background color.)SH
  1266. 9000 56852 MT
  1267. (alpha)SH
  1268. 18000 XM
  1269. (If this is non-zero, an alpha channel will be)
  1270. 54 W( saved.  The presence or absence of an alpha)55 W
  1271. 18000 57957 MT
  1272. (channel has no effect on the value in)SH
  1273. /Times-Italic SF
  1274. 32885 XM
  1275. (ncolors)SH
  1276. /Times-Roman SF
  1277. (.)SH
  1278. 9000 59534 MT
  1279. (background)SH
  1280. 18000 XM
  1281. (Indicates how to treat background pixels.  It has the following values:)SH
  1282. 18000 61325 MT
  1283. (0)SH
  1284. 21600 XM
  1285. (Save all pixels, the background color is ignored.)SH
  1286. 18000 62902 MT
  1287. (1)SH
  1288. 21600 XM
  1289. (Save only non-background)
  1290. 198 W( pixels, but don't set the "clear screen" bit.  This)197 W
  1291. 21600 64007 MT
  1292. (indicates "overlay" mode, a cheap form of compositing \050but see note)
  1293. 205 W( below)206 W
  1294. 21600 65112 MT
  1295. (about this.\051)SH
  1296. 18000 66689 MT
  1297. (2)SH
  1298. 21600 XM
  1299. (Save only non-background pixels, clear the screen to the background color)249 W
  1300. 21600 67794 MT
  1301. (before restoring the image.)SH
  1302. 10800 50 7200 70352 UL
  1303. 6 SS 
  1304. 8000 71691 MT
  1305. (1)SH
  1306. 8 SS 
  1307. 8300 72000 MT
  1308. (E.g., a 16 bit pixel value would not need a filler byte.)SH
  1309. ES
  1310. %%Page: 4 5 
  1311. BS
  1312. 0 SI
  1313. 10 /Times-Roman AF
  1314. 30350 4286 MT
  1315. (4)SH
  1316. 9000 7886 MT
  1317. (xmin, xmax, ymin, ymax)SH
  1318. 18000 8991 MT
  1319. (Inclusive bounds of the image region being saved.)SH
  1320. 9000 10568 MT
  1321. (ncmap)SH
  1322. 18000 XM
  1323. (Number of channels of color map to be)
  1324. 36 W( saved.  The color map will not be saved if this is)35 W
  1325. 18000 11673 MT
  1326. (0.)SH
  1327. 9000 13250 MT
  1328. (cmaplen)SH
  1329. 18000 XM
  1330. (Log base 2 of the number of entries in each channel of the color map.)SH
  1331. 9000 14827 MT
  1332. (cmap)SH
  1333. 18000 XM
  1334. (Pointer to an array containing the color map.  The map)
  1335. 15 W( is saved in "channel major" order.)16 W
  1336. 18000 15932 MT
  1337. (Each entry in the map is a 16 bit)
  1338. 55 W( value with the color value left justified in the word.  If)54 W
  1339. 18000 17037 MT
  1340. (this pointer is NULL, no color map will be saved.)SH
  1341. 9000 18614 MT
  1342. (comments)SH
  1343. 18000 XM
  1344. (Pointer to an array of pointers to strings.  The array is)
  1345. SH( terminated by a NULL pointer \050like)1 W
  1346. /Times-Italic SF
  1347. 18000 19719 MT
  1348. (argv)SH
  1349. /Times-Roman SF
  1350. 20284 XM
  1351. (or)SH
  1352. /Times-Italic SF
  1353. 21568 XM
  1354. (envp)SH
  1355. /Times-Roman SF
  1356. (\051. If)
  1357. 652 W( this pointer is NULL or if the first pointer it)
  1358. 201 W( points to is NULL,)200 W
  1359. 18000 20824 MT
  1360. (comments will not be saved.)SH
  1361. 9000 22401 MT
  1362. (fd)SH
  1363. 18000 XM
  1364. (File \050FILE *\051 pointer to be used for writing or reading the RLE file.)SH
  1365. 9000 23978 MT
  1366. (bits)SH
  1367. 18000 XM
  1368. (A bitmap containing 256 bits.)
  1369. 270 W( A)
  1370. 791 W( channel will be saved \050or retrieved\051 only if the)271 W
  1371. 18000 25083 MT
  1372. (corresponding bit is set in the bitmap.  The alpha channel corresponds to bit 255.)
  1373. 101 W( The)451 W
  1374. 18000 26188 MT
  1375. (bitmap allows an application to easily ignore color channel data that is irrelevant to it.)SH
  1376. 8200 27293 MT
  1377. (The globals structure also contains private)
  1378. 11 W( data for use by the RLE reading and writing routines; data that must be)12 W
  1379. 7200 28398 MT
  1380. (maintained between calls, but that applies to each stream separately.)SH
  1381. 11 /Times-Bold AF
  1382. 7200 32015 MT
  1383. (2.4. Writing RLE files)SH
  1384. 10 /Times-Roman AF
  1385. 8200 33120 MT
  1386. (To create a run-length encoded file, one first)
  1387. 22 W( initializes a globals structure with the relevant information about the)21 W
  1388. 7200 34225 MT
  1389. (image, including the output file descriptor.  The output file should be open and empty.  Then one calls)SH
  1390. /Times-Italic SF
  1391. 48307 XM
  1392. (sv_setup)SH
  1393. /Times-Roman SF
  1394. (:)SH
  1395. /Courier-Bold SF
  1396. 9600 35751 MT
  1397. (sv_setup\050 RUN_DISPATCH, &globals \051;)SH
  1398. /Times-Roman SF
  1399. 7200 37289 MT
  1400. (This writes the file header and initializes the private portions of the global data structure for)
  1401. 104 W( use by the RLE file)105 W
  1402. 7200 38394 MT
  1403. (writing routines.)SH
  1404. 8200 40601 MT
  1405. (The image data must)
  1406. 51 W( be available or expressible in a scanline order \050with the origin at the bottom of the screen\051.)50 W
  1407. 7200 41706 MT
  1408. (After each scanline is computed,)
  1409. 142 W( it is written to the output file by calling one of)143 W
  1410. /Times-Italic SF
  1411. 41508 XM
  1412. (sv_putrow)SH
  1413. /Times-Roman SF
  1414. 46068 XM
  1415. (or)SH
  1416. /Times-Italic SF
  1417. 47294 XM
  1418. (sv_putraw)SH
  1419. /Times-Roman SF
  1420. (. If)
  1421. 536 W( a)143 W
  1422. 7200 42811 MT
  1423. (vertical interval of the image has no data, it may be skipped by calling sv_skiprow:)SH
  1424. /Courier-Bold SF
  1425. 9600 44337 MT
  1426. (/* Skip nrow scanlines */)SH
  1427. 9600 45468 MT
  1428. (sv_skiprow\050 &globals, nrow \051;)SH
  1429. /Times-Roman SF
  1430. 8200 47675 MT
  1431. (If the image data for a scanline is)
  1432. 16 W( available as an array of pixel values,)15 W
  1433. /Times-Italic SF
  1434. 36813 XM
  1435. (sv_putrow)SH
  1436. /Times-Roman SF
  1437. 41245 XM
  1438. (should be used to write the data)15 W
  1439. 7200 48780 MT
  1440. (to the output file.  As an example, let us assume that we have a 512 pixel long)
  1441. 68 W( scanline, with three color channels)69 W
  1442. 7200 49885 MT
  1443. (and no alpha data.  We could call)SH
  1444. /Times-Italic SF
  1445. 20780 XM
  1446. (sv_putrow)SH
  1447. /Times-Roman SF
  1448. 25197 XM
  1449. (as follows:)SH
  1450. /Courier-Bold SF
  1451. 9600 51411 MT
  1452. (rle_pixel scandata[3][512], *rows[3];)SH
  1453. 9600 52542 MT
  1454. (int i;)SH
  1455. 9600 54804 MT
  1456. (for \050 i = 0; i < 3; i++ \051)SH
  1457. 12000 55935 MT
  1458. (rows[i] = scandata[i];)SH
  1459. 9600 57066 MT
  1460. (sv_putrow\050 rows, 512, &globals \051;)SH
  1461. /Times-Roman SF
  1462. 7200 58604 MT
  1463. (Note that)38 W
  1464. /Times-Italic SF
  1465. 11219 XM
  1466. (sv_putrow)SH
  1467. /Times-Roman SF
  1468. 15673 XM
  1469. (is passed an array of pointers to vectors of pixels.  This makes it easy to pass arbitrarily many,)37 W
  1470. 7200 59709 MT
  1471. (and to specify values of)SH
  1472. /Times-Italic SF
  1473. 16948 XM
  1474. (rowlen)SH
  1475. /Times-Roman SF
  1476. 19976 XM
  1477. (different from the size of \050e.g.\051 the)SH
  1478. /Times-Italic SF
  1479. 34055 XM
  1480. (scandata)SH
  1481. /Times-Roman SF
  1482. 37916 XM
  1483. (array.)SH
  1484. 8200 61916 MT
  1485. (The first element of each row of pixels is the pixel at the)61 W
  1486. /Times-Italic SF
  1487. 31850 XM
  1488. (xmin)SH
  1489. /Times-Roman SF
  1490. 34105 XM
  1491. (location in the scanline.  Therefore, when saving)61 W
  1492. 7200 63021 MT
  1493. (only part of an image, one must be careful to set the)SH
  1494. /Times-Italic SF
  1495. 28224 XM
  1496. (rows)SH
  1497. /Times-Roman SF
  1498. 30419 XM
  1499. (pointers to point to the correct pixel in the scanline.)SH
  1500. 8200 65228 MT
  1501. (If an alpha channel is specified to be saved, things)
  1502. 31 W( get a little more complex.  Here is the same example, but now)30 W
  1503. 7200 66333 MT
  1504. (with an alpha channel being saved.)SH
  1505. ES
  1506. %%Page: 5 6 
  1507. BS
  1508. 0 SI
  1509. 10 /Times-Roman AF
  1510. 30350 4286 MT
  1511. (5)SH
  1512. /Courier-Bold SF
  1513. 9600 7874 MT
  1514. (rle_pixel scandata[3][512],)SH
  1515. 15600 9005 MT
  1516. (alpha[512], *rows[4];)SH
  1517. 9600 10136 MT
  1518. (int i;)SH
  1519. 9600 12398 MT
  1520. (rows[0] = alpha;)SH
  1521. 9600 13529 MT
  1522. (for \050 i = 0; i < 3; i++ \051)SH
  1523. 12000 14660 MT
  1524. (rows[i+1] = scandata[i];)SH
  1525. 9600 15791 MT
  1526. (sv_putrow\050 rows+1, 512, &globals \051;)SH
  1527. /Times-Roman SF
  1528. 7200 17329 MT
  1529. (The)SH
  1530. /Times-Italic SF
  1531. 9011 XM
  1532. (sv_putrow)SH
  1533. /Times-Roman SF
  1534. 13434 XM
  1535. (routine expects to find the pointer to)
  1536. 6 W( the alpha channel at the)7 W
  1537. /Symbol SF
  1538. 38008 XM
  1539. (-)SH
  1540. /Times-Roman SF
  1541. (1 position in the rows array.  Thus, we)7 W
  1542. 7200 18434 MT
  1543. (pass a pointer to)SH
  1544. /Times-Italic SF
  1545. 13977 XM
  1546. (rows[1])SH
  1547. /Times-Roman SF
  1548. 17450 XM
  1549. (and put the pointer to the alpha channel in)SH
  1550. /Times-Italic SF
  1551. 34531 XM
  1552. (rows[0])SH
  1553. /Times-Roman SF
  1554. (.)SH
  1555. 8200 20641 MT
  1556. (Finally, after all scanlines have been written, we)
  1557. 47 W( call)46 W
  1558. /Times-Italic SF
  1559. 29922 XM
  1560. (sv_puteof)SH
  1561. /Times-Roman SF
  1562. 34051 XM
  1563. (to write an)46 W
  1564. /Times-Italic SF
  1565. 38716 XM
  1566. (EOF)SH
  1567. /Times-Roman SF
  1568. 40956 XM
  1569. (opcode into the file.  This is not)46 W
  1570. 7200 21746 MT
  1571. (strictly necessary, since a physical end of file also indicates the end of the RLE data, but it is a good idea.)SH
  1572. 8200 23953 MT
  1573. (Here is a skeleton)
  1574. 56 W( of an application that uses)57 W
  1575. /Times-Italic SF
  1576. 26790 XM
  1577. (sv_putrow)SH
  1578. /Times-Roman SF
  1579. 31264 XM
  1580. (to save an image is shown in Figure 2-3.  This example)57 W
  1581. 7200 25058 MT
  1582. (uses the)
  1583. 38 W( default values supplied in the globals variable)37 W
  1584. /Times-Italic SF
  1585. 29559 XM
  1586. (sv_globals)SH
  1587. /Times-Roman SF
  1588. (, modifying it to indicate the presence of an alpha)37 W
  1589. 7200 26163 MT
  1590. (channel.)SH
  1591. 8200 28370 MT
  1592. (Using)SH
  1593. /Times-Italic SF
  1594. 10898 XM
  1595. (sv_putraw)SH
  1596. /Times-Roman SF
  1597. 15374 XM
  1598. (is more complicated, as it)
  1599. 59 W( takes arrays of)60 W
  1600. /Times-Italic SF
  1601. 32430 XM
  1602. (rle_op)SH
  1603. /Times-Roman SF
  1604. 35351 XM
  1605. (structures instead of just pixels.  If the data is)60 W
  1606. 7200 29475 MT
  1607. (already available in something close to this form, however,)42 W
  1608. /Times-Italic SF
  1609. 31491 XM
  1610. (sv_putraw)SH
  1611. /Times-Roman SF
  1612. 35949 XM
  1613. (will run much more quickly than)41 W
  1614. /Times-Italic SF
  1615. 49583 XM
  1616. (sv_putrow)SH
  1617. /Times-Roman SF
  1618. (.)SH
  1619. 7200 30580 MT
  1620. (An)SH
  1621. /Times-Italic SF
  1622. 8672 XM
  1623. (rle_op)SH
  1624. /Times-Roman SF
  1625. 11533 XM
  1626. (is a structure with the following contents:)SH
  1627. 9000 32371 MT
  1628. (opcode)SH
  1629. 18000 XM
  1630. (The type of data.  One of)SH
  1631. /Times-Italic SF
  1632. 28275 XM
  1633. (ByteData)SH
  1634. /Times-Roman SF
  1635. 32302 XM
  1636. (or)SH
  1637. /Times-Italic SF
  1638. 33385 XM
  1639. (RunData)SH
  1640. /Times-Roman SF
  1641. (.)SH
  1642. 9000 33948 MT
  1643. (xloc)SH
  1644. 18000 XM
  1645. (The X location within the scanline at which this data begins.)SH
  1646. 9000 35525 MT
  1647. (length)SH
  1648. 18000 XM
  1649. (The length of the data.  This is either the number of pixels)
  1650. 57 W( that are the same color, for a)58 W
  1651. 18000 36630 MT
  1652. (run, or the number of pixels provided as byte data.)SH
  1653. 9000 38207 MT
  1654. (pixels)SH
  1655. 18000 XM
  1656. (A pointer to an array of pixel values.  This field is used only for the)SH
  1657. /Times-Italic SF
  1658. 45246 XM
  1659. (ByteData)SH
  1660. /Times-Roman SF
  1661. 49273 XM
  1662. (opcode.)SH
  1663. 9000 39784 MT
  1664. (run_val)SH
  1665. 18000 XM
  1666. (The pixel value for a)SH
  1667. /Times-Italic SF
  1668. 26581 XM
  1669. (RunData)SH
  1670. /Times-Roman SF
  1671. 30442 XM
  1672. (opcode.)SH
  1673. 8200 40889 MT
  1674. (Since there is no guarantee that the different color channels will require the same set of)53 W
  1675. /Times-Italic SF
  1676. 44151 XM
  1677. (rle_ops)SH
  1678. /Times-Roman SF
  1679. 47453 XM
  1680. (to describe their)52 W
  1681. 7200 41994 MT
  1682. (data, a separate count must be provided for each channel.  Here is a sample call to)SH
  1683. /Times-Italic SF
  1684. 40219 XM
  1685. (sv_putraw)SH
  1686. /Times-Roman SF
  1687. (:)SH
  1688. /Courier-Bold SF
  1689. 9600 43520 MT
  1690. (int nraw[3];)
  1691. SH( /*)
  1692. 1800 W( Length of each row */)SH
  1693. 9600 44651 MT
  1694. (rle_op *rows[3];/* Data pointers */)SH
  1695. 9600 45782 MT
  1696. (sv_putraw\050 rows, nraw, &globals \051;)SH
  1697. /Times-Roman SF
  1698. 7200 47320 MT
  1699. (A more)
  1700. 70 W( complete example of the use of)71 W
  1701. /Times-Italic SF
  1702. 23819 XM
  1703. (sv_putraw)SH
  1704. /Times-Roman SF
  1705. 28307 XM
  1706. (will be given in connection with the description of)71 W
  1707. /Times-Italic SF
  1708. 49361 XM
  1709. (rle_getraw)SH
  1710. /Times-Roman SF
  1711. (,)SH
  1712. 7200 48425 MT
  1713. (below.)SH
  1714. 8200 50632 MT
  1715. (Calls to)SH
  1716. /Times-Italic SF
  1717. 11534 XM
  1718. (sv_putrow)SH
  1719. /Times-Roman SF
  1720. 15951 XM
  1721. (and)SH
  1722. /Times-Italic SF
  1723. 17645 XM
  1724. (sv_putraw)SH
  1725. /Times-Roman SF
  1726. 22062 XM
  1727. (may be freely intermixed, as required by the application.)SH
  1728. 11 /Times-Bold AF
  1729. 7200 54249 MT
  1730. (2.5. Reading RLE Files)SH
  1731. 10 /Times-Roman AF
  1732. 8200 55354 MT
  1733. (Reading an RLE file is much like writing one.  An initial call to a setup routine reads)
  1734. 57 W( the file header and fills in)56 W
  1735. 7200 56459 MT
  1736. (the)SH
  1737. /Times-Italic SF
  1738. 8672 XM
  1739. (globals)SH
  1740. /Times-Roman SF
  1741. 11867 XM
  1742. (structure. Then,)
  1743. 250 W( a scanline at a time is read by calling)SH
  1744. /Times-Italic SF
  1745. 33696 XM
  1746. (rle_getrow)SH
  1747. /Times-Roman SF
  1748. 38335 XM
  1749. (or)SH
  1750. /Times-Italic SF
  1751. 39418 XM
  1752. (rle_getraw)SH
  1753. /Times-Roman SF
  1754. (.)SH
  1755. 8200 58666 MT
  1756. (The calling program is responsible for opening the input file.  A call to)86 W
  1757. /Times-Italic SF
  1758. 37985 XM
  1759. (rle_get_setup)SH
  1760. /Times-Roman SF
  1761. 43766 XM
  1762. (will then read the header)87 W
  1763. 7200 59771 MT
  1764. (information and fill in the supplied globals structure.  The return code from)139 W
  1765. /Times-Italic SF
  1766. 39392 XM
  1767. (rle_get_setup)SH
  1768. /Times-Roman SF
  1769. 45225 XM
  1770. (indicates a variety)
  1771. 139 W( of)138 W
  1772. 7200 60876 MT
  1773. (errors, such as the input file not being an RLE file, or encountering an EOF while reading the header.)SH
  1774. 8200 63083 MT
  1775. (Each time)36 W
  1776. /Times-Italic SF
  1777. 12549 XM
  1778. (rle_getrow)SH
  1779. /Times-Roman SF
  1780. 17224 XM
  1781. (is called, it fills in the)
  1782. 36 W( supplied scanline buffer with one scanline of image data and returns)37 W
  1783. 7200 64188 MT
  1784. (the Y position of the scanline \050which will be one greater than the previous time it was)
  1785. 81 W( called\051.  Depending on the)80 W
  1786. 7200 65293 MT
  1787. (setting of the)43 W
  1788. /Times-Italic SF
  1789. 12801 XM
  1790. (background)SH
  1791. /Times-Roman SF
  1792. 17871 XM
  1793. (flag, the scanline buffer may or may not be cleared to)
  1794. 43 W( the background color on each call.)44 W
  1795. 7200 66398 MT
  1796. (If it)
  1797. 84 W( is not \050)83 W
  1798. /Times-Italic SF
  1799. (background)SH
  1800. /Times-Roman SF
  1801. 17143 XM
  1802. (is 0 or 1\051, and if the caller does not clear the buffer between scanlines, then a "smearing")83 W
  1803. 7200 67503 MT
  1804. (effect will be seen, if some pixels from previous scanlines are not overwritten by pixels on)
  1805. 125 W( the current scanline.)126 W
  1806. 7200 68608 MT
  1807. (Note that if)141 W
  1808. /Times-Italic SF
  1809. 12428 XM
  1810. (background)SH
  1811. /Times-Roman SF
  1812. 17596 XM
  1813. (is 0, then no background color was supplied, and setting)140 W
  1814. /Times-Italic SF
  1815. 41716 XM
  1816. (background)SH
  1817. /Times-Roman SF
  1818. 46883 XM
  1819. (to 2 to try to get)140 W
  1820. 7200 69713 MT
  1821. (automatic buffer clearing will usually cause a segmentation fault when)40 W
  1822. /Times-Italic SF
  1823. 36150 XM
  1824. (rle_getrow)SH
  1825. /Times-Roman SF
  1826. 40829 XM
  1827. (tries to get the background)
  1828. 40 W( color)41 W
  1829. 7200 70818 MT
  1830. (through the)SH
  1831. /Times-Italic SF
  1832. 12033 XM
  1833. (bg_color)SH
  1834. /Times-Roman SF
  1835. 15894 XM
  1836. (pointer.)SH
  1837. ES
  1838. %%Page: 6 7 
  1839. BS
  1840. 0 SI
  1841. 10 /Times-Roman AF
  1842. 30350 4286 MT
  1843. (6)SH
  1844. /Courier-Bold SF
  1845. 9600 7874 MT
  1846. (#include <svfb_global.h>)SH
  1847. 9600 10136 MT
  1848. (main\050\051)SH
  1849. 9600 11267 MT
  1850. ({)SH
  1851. 14400 12398 MT
  1852. (rle_pixel scanline[3][512], alpha[512], *rows[4];)SH
  1853. 14400 13529 MT
  1854. (int y, i;)SH
  1855. 14400 15791 MT
  1856. (/* Most of the default values in sv_globals are ok */)SH
  1857. 14400 16922 MT
  1858. (/* We do have an alpha channel, though */)SH
  1859. 14400 18053 MT
  1860. (sv_globals.sv_alpha = 1;)SH
  1861. 14400 19184 MT
  1862. (SV_SET_BIT\050 sv_globals, SV_ALPHA \051;)SH
  1863. 14400 21446 MT
  1864. (rows[0] = alpha;)SH
  1865. 14400 22577 MT
  1866. (for \050 i = 0; i < 3; i++ \051)SH
  1867. 19200 23708 MT
  1868. (rows[i+1] = scanline[i];)SH
  1869. 14400 25970 MT
  1870. (sv_setup\050 RUN_DISPATCH, &sv_globals \051;)SH
  1871. 14400 28232 MT
  1872. (/* Create output for 512 x 480 \050default size\051 display */)SH
  1873. 14400 29363 MT
  1874. (for \050 y = 0; y < 480; y++ \051)SH
  1875. 14400 30494 MT
  1876. ({)SH
  1877. 19200 31625 MT
  1878. (mk_scanline\050 y, scanline, alpha \051;)SH
  1879. 19200 32756 MT
  1880. (sv_putrow\050 rows, 512, &sv_globals \051;)SH
  1881. 14400 33887 MT
  1882. (})SH
  1883. 14400 35018 MT
  1884. (sv_puteof\050 &sv_globals \051;)SH
  1885. 9600 36149 MT
  1886. (})SH
  1887. /Times-Bold SF
  1888. 21962 37759 MT
  1889. (Figure 2-3:)SH
  1890. /Times-Roman SF
  1891. 27461 XM
  1892. (Example of use of sv_putrow)SH
  1893. 8200 39966 MT
  1894. (Figure 2-4 shows an)
  1895. 92 W( example of the use of)91 W
  1896. /Times-Italic SF
  1897. 26269 XM
  1898. (rle_getrow)SH
  1899. /Times-Roman SF
  1900. (. Note)
  1901. 432 W( the dynamic allocation of scanline storage space,)91 W
  1902. 7200 41071 MT
  1903. (and compensation for presence of an alpha channel.  A subroutine,)132 W
  1904. /Times-Italic SF
  1905. 35562 XM
  1906. (rle_row_alloc)SH
  1907. /Times-Roman SF
  1908. (, is available that)
  1909. 132 W( performs the)133 W
  1910. 7200 42176 MT
  1911. (storage allocation automatically.  It is described below.)
  1912. 348 W( If)
  1913. 945 W( the alpha channel were irrelevant, the macro)347 W
  1914. /Times-Italic SF
  1915. 7200 43281 MT
  1916. (SV_CLR_BIT)SH
  1917. /Times-Roman SF
  1918. 12895 XM
  1919. (could be used to inhibit reading it, and no storage space would be needed for it.)SH
  1920. 8200 45488 MT
  1921. (The function)20 W
  1922. /Times-Italic SF
  1923. 13628 XM
  1924. (rle_getraw)SH
  1925. /Times-Roman SF
  1926. 18287 XM
  1927. (is the inverse of)21 W
  1928. /Times-Italic SF
  1929. 24981 XM
  1930. (sv_putraw)SH
  1931. /Times-Roman SF
  1932. (. When)
  1933. 292 W( called, it fills in the supplied buffer with raw data for)21 W
  1934. 8 SS 
  1935. 30129 46256 MT
  1936. (15)SH
  1937. 10 SS 
  1938. 7200 46601 MT
  1939. (a single scanline.  It returns the scanline)62 W
  1940. /Times-Italic SF
  1941. 23943 XM
  1942. (y)SH
  1943. /Times-Roman SF
  1944. 24699 XM
  1945. (position, or 2)62 W
  1946. 31241 XM
  1947. (to indicate)
  1948. 62 W( end of file.  It is assumed that no image will)61 W
  1949. 8 SS 
  1950. 14594 47369 MT
  1951. (15)SH
  1952. 10 SS 
  1953. 7200 47714 MT
  1954. (have more)
  1955. 159 W( than 2)160 W
  1956. /Symbol SF
  1957. 15394 XM
  1958. (-)SH
  1959. /Times-Roman SF
  1960. (1 scanlines.  A complete program \050except for error checking\051 that reads an RLE file from)160 W
  1961. 7200 48819 MT
  1962. (standard input and produces a negative image on standard output is shown in Figure 2-5.)SH
  1963. 8200 51026 MT
  1964. (The functions)132 W
  1965. /Times-Italic SF
  1966. 14241 XM
  1967. (rle_row_alloc)SH
  1968. /Times-Roman SF
  1969. 20290 XM
  1970. (and)SH
  1971. /Times-Italic SF
  1972. 22116 XM
  1973. (rle_raw_alloc)SH
  1974. /Times-Roman SF
  1975. 28165 XM
  1976. (simplify allocation of)
  1977. 132 W( buffer space for use by the rle routines.)131 W
  1978. 7200 52131 MT
  1979. (Both use a supplied globals structure to determine how many and which channels need buffer)
  1980. 54 W( space, as well as the)55 W
  1981. 7200 53236 MT
  1982. (size of the buffer for each scanline.  The)
  1983. 151 W( returned buffer pointers will be adjusted for the presence of an alpha)150 W
  1984. 7200 54341 MT
  1985. (channel, if it is present.  Buffer space for pixel or)39 W
  1986. /Times-Italic SF
  1987. 27541 XM
  1988. (rle_op)SH
  1989. /Times-Roman SF
  1990. 30441 XM
  1991. (data will be allocate only)
  1992. 39 W( for those channels that have bits)40 W
  1993. 7200 55446 MT
  1994. (set in the channel bitmap.  The buffer space may be freed by calling)SH
  1995. /Times-Italic SF
  1996. 34610 XM
  1997. (rle_row_free)SH
  1998. /Times-Roman SF
  1999. 40082 XM
  2000. (or)SH
  2001. /Times-Italic SF
  2002. 41165 XM
  2003. (rle_raw_free)SH
  2004. /Times-Roman SF
  2005. (, respectively.)SH
  2006. 12 /Times-Bold AF
  2007. 7200 59130 MT
  2008. (3. Comments, issues, and directions)SH
  2009. 10 /Times-Roman AF
  2010. 8200 60235 MT
  2011. (Some comments on the file format and current subroutine implementation:)SH
  2012. /Symbol SF
  2013. 8990 61688 MT
  2014. (\267)SH
  2015. /Times-Roman SF
  2016. 9700 XM
  2017. (The background color for the alpha channel is always 0.)SH
  2018. /Symbol SF
  2019. 8990 63446 MT
  2020. (\267)SH
  2021. /Times-Roman SF
  2022. 9700 XM
  2023. (All channels must have the same number of bits.  This could be a problem when saving, e.g., Z values,)38 W
  2024. 9700 64551 MT
  2025. (or if more than 8 bits of precision were desired for the alpha channel.)SH
  2026. /Symbol SF
  2027. 8990 66309 MT
  2028. (\267)SH
  2029. /Times-Roman SF
  2030. 9700 XM
  2031. (Pixels are skipped \050by)42 W
  2032. /Times-Italic SF
  2033. 18978 XM
  2034. (sv_putrow)SH
  2035. /Times-Roman SF
  2036. (\051 only if all channel)
  2037. 42 W( values of the pixel are equal to the corresponding)43 W
  2038. 9700 67414 MT
  2039. (background color values.)SH
  2040. /Symbol SF
  2041. 8990 69172 MT
  2042. (\267)SH
  2043. /Times-Roman SF
  2044. 9700 XM
  2045. (The current Implementation of)49 W
  2046. /Times-Italic SF
  2047. 22449 XM
  2048. (sv_putrow)SH
  2049. /Times-Roman SF
  2050. 26915 XM
  2051. (skips pixels only if at least 2 adjacent pixels are equal to the)49 W
  2052. 9700 70277 MT
  2053. (background. The)
  2054. 250 W( SkipPixels operation is intended for efficiency, not to provide cheap compositing.)SH
  2055. ES
  2056. %%Page: 7 8 
  2057. BS
  2058. 0 SI
  2059. 10 /Times-Roman AF
  2060. 30350 4286 MT
  2061. (7)SH
  2062. /Courier-Bold SF
  2063. 9600 7874 MT
  2064. (/* An example of using rle_getrow */)SH
  2065. 9600 9005 MT
  2066. (/* Scanline pointer */)SH
  2067. 9600 10136 MT
  2068. (rle_pixel ** scan;)SH
  2069. 9600 11267 MT
  2070. (int i;)SH
  2071. 9600 13529 MT
  2072. (/* Read the RLE file from stdin */)SH
  2073. 9600 14660 MT
  2074. (rle_get_setup\050 &globals \051;)SH
  2075. 9600 16922 MT
  2076. (/* Allocate enough space for scanline data, including alpha channel */)SH
  2077. 9600 18053 MT
  2078. (/* \050Should check for non-zero return, indicating a malloc error\051 */)SH
  2079. 9600 19184 MT
  2080. (rle_row_alloc\050 &globals, &scan \051;)SH
  2081. 9600 21446 MT
  2082. (/* Read scanline data */)SH
  2083. 9600 22577 MT
  2084. (while \050 \050y = rle_getrow\050 &globals, stdin, scan \051 <= globals.sv_ymax \051)SH
  2085. 14400 23708 MT
  2086. (/* Use the scanline data */;)SH
  2087. /Times-Bold SF
  2088. 22324 26449 MT
  2089. (Figure 2-4:)SH
  2090. /Times-Roman SF
  2091. 27823 XM
  2092. (Example of rle_getrow use.)SH
  2093. /Symbol SF
  2094. 8990 28354 MT
  2095. (\267)SH
  2096. /Times-Roman SF
  2097. 9700 XM
  2098. (Nothing forces the image data to lie within the bounds declared in the header.  However,)106 W
  2099. /Times-Italic SF
  2100. 47111 XM
  2101. (rle_getrow)SH
  2102. /Times-Roman SF
  2103. 9700 29459 MT
  2104. (will not)
  2105. 256 W( write outside these bounds, to prevent core dumps.  No such protection is provided by)255 W
  2106. /Times-Italic SF
  2107. 9700 30564 MT
  2108. (rle_getraw)SH
  2109. /Times-Roman SF
  2110. (.)SH
  2111. /Symbol SF
  2112. 8990 32322 MT
  2113. (\267)SH
  2114. /Times-Roman SF
  2115. 9700 XM
  2116. (Images saved in RLE are usually about 1/3 their original size)
  2117. 230 W( \050for an "average" image\051.  Highly)231 W
  2118. 9700 33427 MT
  2119. (complex images may end up slightly larger than they would have been if saved by the trivial method.)SH
  2120. 8200 35634 MT
  2121. (We have not yet decided how pixels with)
  2122. 72 W( other than 8 bits should be packed into the file.  To keep the file size)71 W
  2123. 7200 36739 MT
  2124. (down, one would like to pack)29 W
  2125. /Times-Italic SF
  2126. 19456 XM
  2127. (ByteData)SH
  2128. /Times-Roman SF
  2129. 23512 XM
  2130. (as tightly as possible.  However,)
  2131. 29 W( for interpretation speed, it would probably)30 W
  2132. 7200 37844 MT
  2133. (be better to save one value in each \050)SH
  2134. /Times-Italic SF
  2135. (pixelbits)SH
  2136. /Times-Roman SF
  2137. (+7\051/8 bytes.)SH
  2138. 8200 40051 MT
  2139. (Some proposed enhancements include:)SH
  2140. /Symbol SF
  2141. 8990 41504 MT
  2142. (\267)SH
  2143. /Times-Roman SF
  2144. 9700 XM
  2145. (A "ramp" opcode.  This specifies that pixel values should)
  2146. 49 W( be linearly ramped between two values for a)48 W
  2147. 9700 42609 MT
  2148. (given number)
  2149. 2 W( of pixels in the scanline.  This opcode would be difficult to generate from an image, but if)3 W
  2150. 9700 43714 MT
  2151. (an application knew it was generating a ramp,)
  2152. 133 W( it could produce significant file size savings \050e.g.  in)132 W
  2153. 9700 44819 MT
  2154. (Gouraud shaded images\051.)SH
  2155. /Symbol SF
  2156. 8990 46577 MT
  2157. (\267)SH
  2158. /Times-Roman SF
  2159. 9700 XM
  2160. (Opcodes indicating that the current scanline)
  2161. 86 W( is identical to the previous, or that it differs only slightly)87 W
  2162. 9700 47682 MT
  2163. (\050presumably followed by standard opcodes)
  2164. 75 W( indicating the difference\051.  Detection of identical scanlines)74 W
  2165. 9700 48787 MT
  2166. (is easy, deciding that a scanline differs slightly enough)
  2167. 120 W( to warrant a differential description could be)121 W
  2168. 8 SS 
  2169. 44306 49555 MT
  2170. (2)SH
  2171. 10 SS 
  2172. 9700 49900 MT
  2173. (difficult. In)
  2174. 250 W( images with large areas with little change, this could produce size savings)SH
  2175. 8200 52107 MT
  2176. (The subroutine library is still missing some useful functions.  Some proposed additions are:)SH
  2177. /Symbol SF
  2178. 8990 53560 MT
  2179. (\267)SH
  2180. /Times-Roman SF
  2181. 9700 XM
  2182. (Conversion from "raw")
  2183. 27 W( to "row" format, and back.  One could then view)26 W
  2184. /Times-Italic SF
  2185. 39361 XM
  2186. (sv_putrow)SH
  2187. /Times-Roman SF
  2188. 43804 XM
  2189. (as being a "raw" to)26 W
  2190. 9700 54665 MT
  2191. ("row" conversion followed by a call to)70 W
  2192. /Times-Italic SF
  2193. 25920 XM
  2194. (sv_putraw)SH
  2195. /Times-Roman SF
  2196. (, and)70 W
  2197. /Times-Italic SF
  2198. 32421 XM
  2199. (rle_getrow)SH
  2200. /Times-Roman SF
  2201. 37131 XM
  2202. (as a call to)71 W
  2203. /Times-Italic SF
  2204. 41914 XM
  2205. (rle_getraw)SH
  2206. /Times-Roman SF
  2207. 46624 XM
  2208. (followed by)71 W
  2209. 9700 55770 MT
  2210. ("row" to "raw" conversion.)SH
  2211. /Symbol SF
  2212. 8990 57528 MT
  2213. (\267)SH
  2214. /Times-Roman SF
  2215. 9700 XM
  2216. (A function to merge several)
  2217. 25 W( channels of "raw" data into a single channel.  For example, this would take)24 W
  2218. 9700 58633 MT
  2219. (separate red, green, and blue)
  2220. 99 W( channels and combine them into a single RGB channel.  This would be)100 W
  2221. 9700 59738 MT
  2222. (useful for)
  2223. 14 W( RLE interpretation on devices that do not easily support the separate channel paradigm, while)13 W
  2224. 9700 60843 MT
  2225. (preserving the efficiency of the "raw" interface.  It could also be)
  2226. 109 W( used to increase the efficiency of a)110 W
  2227. 9700 61948 MT
  2228. (compositing program.)SH
  2229. 8200 64155 MT
  2230. (The Utah RLE format has developed and matured over a period of about six years, and has proven to be versatile)28 W
  2231. 7200 65260 MT
  2232. (and useful for a wide)
  2233. 146 W( variety of applications that require image transmittal and storage.  It provides a compact,)147 W
  2234. 7200 66365 MT
  2235. (efficiently interpreted image storage capability.  We expect to see continued development of)
  2236. 30 W( capabilities and utility,)29 W
  2237. 7200 67470 MT
  2238. (but expect very little change in the basic format.)SH
  2239. 10800 50 7200 70352 UL
  2240. 6 SS 
  2241. 8000 71691 MT
  2242. (2)SH
  2243. 8 SS 
  2244. 8300 72000 MT
  2245. (This suggestion was inspired by a description of the RLE format used at Ohio State University.)SH
  2246. ES
  2247. %%Page: 8 9 
  2248. BS
  2249. 0 SI
  2250. 10 /Times-Roman AF
  2251. 30350 4286 MT
  2252. (8)SH
  2253. /Courier-Bold SF
  2254. 9600 7874 MT
  2255. (#include <stdio.h>)SH
  2256. 9600 9005 MT
  2257. (#include <svfb_global.h>)SH
  2258. 9600 10136 MT
  2259. (#include <rle_getraw.h>)SH
  2260. 9600 12398 MT
  2261. (main\050\051)SH
  2262. 9600 13529 MT
  2263. ({)SH
  2264. 12000 14660 MT
  2265. (struct sv_globals in_glob, out_glob;)SH
  2266. 12000 15791 MT
  2267. (rle_op ** scan;)SH
  2268. 12000 16922 MT
  2269. (int * nraw, i, j, c, y, newy;)SH
  2270. 12000 19184 MT
  2271. (in_glob.svfb_fd = stdin;)SH
  2272. 12000 20315 MT
  2273. (rle_get_setup\050 &in_glob \051;)SH
  2274. 12000 21446 MT
  2275. (/* Copy setup information from input to output file */)SH
  2276. 12000 22577 MT
  2277. (out_glob = in_glob;)SH
  2278. 12000 23708 MT
  2279. (out_glob.svfb_fd = stdout;)SH
  2280. 12000 25970 MT
  2281. (/* Get storage for calling rle_getraw */)SH
  2282. 12000 27101 MT
  2283. (rle_raw_alloc\050 &in_glob, &scan, &nraw \051;)SH
  2284. 12000 29363 MT
  2285. (/* Negate background color! */)SH
  2286. 12000 30494 MT
  2287. (if \050 in_glob.sv_background \051)SH
  2288. 14400 31625 MT
  2289. (for \050 i = 0; i < in_glob.sv_ncolors; i++ \051)SH
  2290. 16800 32756 MT
  2291. (out_glob.sv_bg_color[i] = 255 - out_glob.sv_bg_color[i];)SH
  2292. 12000 35018 MT
  2293. (/* Init output file */)SH
  2294. 12000 36149 MT
  2295. (sv_setup\050 RUN_DISPATCH, &out_glob \051;)SH
  2296. 12000 38411 MT
  2297. (y = in_glob.sv_ymin;)SH
  2298. 12000 39542 MT
  2299. (while \050 \050newy = rle_getraw\050 &in_glob, scan, nraw \051\051 != 32768 \051 {)SH
  2300. 14400 40673 MT
  2301. (/* If > one line skipped in input, do same in output */)SH
  2302. 14400 41804 MT
  2303. (if \050 newy - y > 1 \051)SH
  2304. 16800 42935 MT
  2305. (sv_skiprow\050 &out_glob, newy - y \051;)SH
  2306. 14400 44066 MT
  2307. (y = newy;)SH
  2308. 14400 45197 MT
  2309. (/* Map all color channels */)SH
  2310. 14400 46328 MT
  2311. (for \050 c = 0; c < out_glob.sv_ncolors; c++ \051)SH
  2312. 16800 47459 MT
  2313. (for \050 i = 0; i < nraw[c]; i++ \051)SH
  2314. 19200 48590 MT
  2315. (switch\050 scan[c][i].opcode \051 {)SH
  2316. 19200 49721 MT
  2317. (case RRunDataOp:)SH
  2318. 21600 50852 MT
  2319. (scan[c][i].u.run_val = 255 - scan[c][i].u.run_val;)SH
  2320. 21600 51983 MT
  2321. (break;)SH
  2322. 19200 53114 MT
  2323. (case RByteDataOp:)SH
  2324. 21600 54245 MT
  2325. (for \050 j = 0; j < scan[c][i].length; j++ \051)SH
  2326. 24000 55376 MT
  2327. (scan[c][i].u.pixels[j] =)SH
  2328. 26400 56507 MT
  2329. (255 - scan[c][i].u.pixels[j];)SH
  2330. 21600 57638 MT
  2331. (break;)SH
  2332. 19200 58769 MT
  2333. (})SH
  2334. 14400 59900 MT
  2335. (sv_putraw\050 scan, nraw, &out_glob \051;)SH
  2336. 14400 61031 MT
  2337. (/* Free raw data */)SH
  2338. 14400 62162 MT
  2339. (rle_freeraw\050 &in_glob, scan, nraw \051;)SH
  2340. 12000 63293 MT
  2341. (})SH
  2342. 12000 64424 MT
  2343. (sv_puteof\050 &out_glob \051;)SH
  2344. 12000 66686 MT
  2345. (/* Free storage */)SH
  2346. 12000 67817 MT
  2347. (rle_raw_free\050 &in_glob, scan, nraw \051;)SH
  2348. 9600 68948 MT
  2349. (})SH
  2350. /Times-Bold SF
  2351. 19227 71689 MT
  2352. (Figure 2-5:)SH
  2353. /Times-Roman SF
  2354. 24726 XM
  2355. (Program to produce a negative of an image)SH
  2356. ES
  2357. %%Page: 9 10 
  2358. BS
  2359. 0 SI
  2360. 10 /Times-Roman AF
  2361. 30350 4286 MT
  2362. (9)SH
  2363. 12 /Times-Bold AF
  2364. 7200 8004 MT
  2365. (4. Acknowledgments)SH
  2366. 10 /Times-Roman AF
  2367. 8200 9109 MT
  2368. (This work was supported)
  2369. 138 W( in part by the National Science Foundation \050DCR-8203692 and DCR-8121750\051, the)139 W
  2370. 7200 10214 MT
  2371. (Defense Advanced Research Projects Agency \050DAAK11-84-K-0017\051, the Army)
  2372. 179 W( Research Office \050DAAG29-81-)178 W
  2373. 7200 11319 MT
  2374. (K-0111\051, and the Office of Naval Research \050N00014-82-K-0351\051.  All opinions,)
  2375. 376 W( findings, conclusions or)377 W
  2376. 7200 12424 MT
  2377. (recommendations expressed in this document are those)
  2378. 24 W( of the authors and do not necessarily reflect the views of the)23 W
  2379. 7200 13529 MT
  2380. (sponsoring agencies.)SH
  2381. ES
  2382. %%Page: i 11 
  2383. BS
  2384. 0 SI
  2385. 10 /Times-Roman AF
  2386. 30461 4286 MT
  2387. (i)SH
  2388. 12 /Times-Bold AF
  2389. 26033 8004 MT
  2390. (Table of Contents)SH
  2391. 11 SS 
  2392. 8850 9172 MT
  2393. (1. Introduction)SH
  2394. 53450 XM
  2395. (0)SH
  2396. 8850 10340 MT
  2397. (2. Description of RLE Format)SH
  2398. 53450 XM
  2399. (0)SH
  2400. 10 SS 
  2401. 10700 11420 MT
  2402. (2.1. The Header)SH
  2403. 53500 XM
  2404. (1)SH
  2405. 10700 12500 MT
  2406. (2.2. The Scanline Data)SH
  2407. 53500 XM
  2408. (2)SH
  2409. 10700 13580 MT
  2410. (2.3. Subroutine Interface)SH
  2411. 53500 XM
  2412. (3)SH
  2413. 10700 14660 MT
  2414. (2.4. Writing RLE files)SH
  2415. 53500 XM
  2416. (4)SH
  2417. 10700 15740 MT
  2418. (2.5. Reading RLE Files)SH
  2419. 53500 XM
  2420. (5)SH
  2421. 11 SS 
  2422. 8850 16908 MT
  2423. (3. Comments, issues, and directions)SH
  2424. 53450 XM
  2425. (6)SH
  2426. 8850 18076 MT
  2427. (4. Acknowledgments)SH
  2428. 53450 XM
  2429. (9)SH
  2430. ES
  2431. %%Page: ii 12 
  2432. BS
  2433. 0 SI
  2434. 10 /Times-Roman AF
  2435. 30322 4286 MT
  2436. (ii)SH
  2437. 12 /Times-Bold AF
  2438. 26866 8004 MT
  2439. (List of Figures)SH
  2440. 11 SS 
  2441. 8850 9172 MT
  2442. (Figure 2-1:)
  2443. SH( RLE)
  2444. 550 W( file header)SH
  2445. 53450 XM
  2446. (1)SH
  2447. 8850 10340 MT
  2448. (Figure 2-2:)
  2449. SH( RLE)
  2450. 550 W( file operand formats)SH
  2451. 53450 XM
  2452. (2)SH
  2453. 8850 11508 MT
  2454. (Figure 2-3:)
  2455. SH( Example)
  2456. 550 W( of use of sv_putrow)SH
  2457. 53450 XM
  2458. (6)SH
  2459. 8850 12676 MT
  2460. (Figure 2-4:)
  2461. SH( Example)
  2462. 550 W( of rle_getrow use.)SH
  2463. 53450 XM
  2464. (7)SH
  2465. 8850 13844 MT
  2466. (Figure 2-5:)
  2467. SH( Program)
  2468. 550 W( to produce a negative of an image)SH
  2469. 53450 XM
  2470. (8)SH
  2471. ES
  2472. %%Trailer
  2473. %%Pages: 12 
  2474. %%DocumentFonts: Times-Roman Times-Bold Times-Italic Symbol Courier-Bold
  2475.